rustfmt. removed gating on creating user rows for join sounds
This commit is contained in:
parent
b34ac64172
commit
f75af926f5
2
rustfmt.toml
Normal file
2
rustfmt.toml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
imports_granularity = "Crate"
|
||||||
|
group_imports = "StdExternalCrate"
|
@ -1,15 +1,13 @@
|
|||||||
use regex_command_attr::command;
|
use std::{collections::HashMap, sync::Arc};
|
||||||
|
|
||||||
|
use regex_command_attr::command;
|
||||||
use serenity::{client::Context, framework::standard::CommandResult};
|
use serenity::{client::Context, framework::standard::CommandResult};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
framework::{Args, CommandInvoke, CreateGenericResponse, RegexFramework},
|
framework::{Args, CommandInvoke, CommandKind, CreateGenericResponse, RegexFramework},
|
||||||
THEME_COLOR,
|
THEME_COLOR,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::framework::CommandKind;
|
|
||||||
use std::{collections::HashMap, sync::Arc};
|
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[group("Information")]
|
#[group("Information")]
|
||||||
#[description("Get information on the commands of the bot")]
|
#[description("Get information on the commands of the bot")]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use regex_command_attr::command;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use regex_command_attr::command;
|
||||||
use serenity::{
|
use serenity::{
|
||||||
client::Context,
|
client::Context,
|
||||||
framework::standard::CommandResult,
|
framework::standard::CommandResult,
|
||||||
@ -12,8 +13,6 @@ use crate::{
|
|||||||
MySQL, MAX_SOUNDS, PATREON_GUILD, PATREON_ROLE,
|
MySQL, MAX_SOUNDS, PATREON_GUILD, PATREON_ROLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
#[command("upload")]
|
#[command("upload")]
|
||||||
#[group("Manage")]
|
#[group("Manage")]
|
||||||
#[description("Upload a new sound to the bot")]
|
#[description("Upload a new sound to the bot")]
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use regex_command_attr::command;
|
use std::{convert::TryFrom, time::Duration};
|
||||||
|
|
||||||
|
use regex_command_attr::command;
|
||||||
use serenity::{
|
use serenity::{
|
||||||
builder::CreateActionRow,
|
builder::CreateActionRow,
|
||||||
client::Context,
|
client::Context,
|
||||||
framework::standard::CommandResult,
|
framework::standard::CommandResult,
|
||||||
model::interactions::{message_component::ButtonStyle, InteractionResponseType},
|
model::interactions::{message_component::ButtonStyle, InteractionResponseType},
|
||||||
};
|
};
|
||||||
|
|
||||||
use songbird::{
|
use songbird::{
|
||||||
create_player, ffmpeg,
|
create_player, ffmpeg,
|
||||||
input::{cached::Memory, Input},
|
input::{cached::Memory, Input},
|
||||||
@ -22,8 +22,6 @@ use crate::{
|
|||||||
AudioIndex, MySQL,
|
AudioIndex, MySQL,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::{convert::TryFrom, time::Duration};
|
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[aliases("p")]
|
#[aliases("p")]
|
||||||
#[required_permissions(Managed)]
|
#[required_permissions(Managed)]
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use regex_command_attr::command;
|
use regex_command_attr::command;
|
||||||
|
|
||||||
use serenity::{client::Context, framework::standard::CommandResult};
|
use serenity::{client::Context, framework::standard::CommandResult};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use regex_command_attr::command;
|
use regex_command_attr::command;
|
||||||
|
|
||||||
use serenity::{client::Context, framework::standard::CommandResult};
|
use serenity::{client::Context, framework::standard::CommandResult};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
use regex_command_attr::command;
|
use regex_command_attr::command;
|
||||||
|
|
||||||
use serenity::{client::Context, framework::standard::CommandResult};
|
use serenity::{client::Context, framework::standard::CommandResult};
|
||||||
|
use songbird;
|
||||||
|
|
||||||
use crate::framework::{Args, CommandInvoke, CreateGenericResponse};
|
use crate::framework::{Args, CommandInvoke, CreateGenericResponse};
|
||||||
|
|
||||||
use songbird;
|
|
||||||
|
|
||||||
#[command("stop")]
|
#[command("stop")]
|
||||||
#[required_permissions(Managed)]
|
#[required_permissions(Managed)]
|
||||||
#[group("Stop")]
|
#[group("Stop")]
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
use crate::{
|
use std::{collections::HashMap, env};
|
||||||
framework::RegexFramework,
|
|
||||||
guild_data::CtxGuildData,
|
|
||||||
join_channel, play_audio, play_from_query,
|
|
||||||
sound::{JoinSoundCtx, Sound},
|
|
||||||
MySQL, ReqwestClient,
|
|
||||||
};
|
|
||||||
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
async_trait,
|
async_trait,
|
||||||
@ -19,12 +13,15 @@ use serenity::{
|
|||||||
},
|
},
|
||||||
utils::shard_id,
|
utils::shard_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
use songbird::{Event, EventContext, EventHandler as SongbirdEventHandler};
|
use songbird::{Event, EventContext, EventHandler as SongbirdEventHandler};
|
||||||
|
|
||||||
use crate::framework::Args;
|
use crate::{
|
||||||
|
framework::{Args, RegexFramework},
|
||||||
use std::{collections::HashMap, env};
|
guild_data::CtxGuildData,
|
||||||
|
join_channel, play_audio, play_from_query,
|
||||||
|
sound::{JoinSoundCtx, Sound},
|
||||||
|
MySQL, ReqwestClient,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct RestartTrack;
|
pub struct RestartTrack;
|
||||||
|
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
|
use std::{
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
env, fmt,
|
||||||
|
hash::{Hash, Hasher},
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
|
|
||||||
|
use log::{debug, error, info, warn};
|
||||||
|
use regex::{Match, Regex, RegexBuilder};
|
||||||
|
use serde_json::Value;
|
||||||
use serenity::{
|
use serenity::{
|
||||||
async_trait,
|
async_trait,
|
||||||
builder::CreateEmbed,
|
builder::{CreateComponents, CreateEmbed},
|
||||||
cache::Cache,
|
cache::Cache,
|
||||||
client::Context,
|
client::Context,
|
||||||
framework::{standard::CommandResult, Framework},
|
framework::{standard::CommandResult, Framework},
|
||||||
@ -9,7 +19,7 @@ use serenity::{
|
|||||||
model::{
|
model::{
|
||||||
channel::{Channel, GuildChannel, Message},
|
channel::{Channel, GuildChannel, Message},
|
||||||
guild::{Guild, Member},
|
guild::{Guild, Member},
|
||||||
id::{ChannelId, GuildId, UserId},
|
id::{ChannelId, GuildId, RoleId, UserId},
|
||||||
interactions::{
|
interactions::{
|
||||||
application_command::{
|
application_command::{
|
||||||
ApplicationCommand, ApplicationCommandInteraction, ApplicationCommandOptionType,
|
ApplicationCommand, ApplicationCommandInteraction, ApplicationCommandOptionType,
|
||||||
@ -21,21 +31,7 @@ use serenity::{
|
|||||||
Result as SerenityResult,
|
Result as SerenityResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
use log::{debug, error, info, warn};
|
|
||||||
|
|
||||||
use regex::{Match, Regex, RegexBuilder};
|
|
||||||
|
|
||||||
use std::{
|
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
env, fmt,
|
|
||||||
hash::{Hash, Hasher},
|
|
||||||
sync::Arc,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::guild_data::CtxGuildData;
|
use crate::guild_data::CtxGuildData;
|
||||||
use serde_json::Value;
|
|
||||||
use serenity::builder::CreateComponents;
|
|
||||||
use serenity::model::id::RoleId;
|
|
||||||
|
|
||||||
type CommandFn = for<'fut> fn(
|
type CommandFn = for<'fut> fn(
|
||||||
&'fut Context,
|
&'fut Context,
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
use crate::{GuildDataCache, MySQL};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use serenity::{async_trait, model::id::GuildId, prelude::Context};
|
use serenity::{async_trait, model::id::GuildId, prelude::Context};
|
||||||
use sqlx::mysql::MySqlPool;
|
use sqlx::mysql::MySqlPool;
|
||||||
use std::sync::Arc;
|
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
|
use crate::{GuildDataCache, MySQL};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct GuildData {
|
pub struct GuildData {
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
|
26
src/main.rs
26
src/main.rs
@ -8,15 +8,11 @@ mod framework;
|
|||||||
mod guild_data;
|
mod guild_data;
|
||||||
mod sound;
|
mod sound;
|
||||||
|
|
||||||
use crate::{
|
use std::{collections::HashMap, env, sync::Arc};
|
||||||
event_handlers::Handler,
|
|
||||||
framework::{Args, RegexFramework},
|
|
||||||
guild_data::{CtxGuildData, GuildData},
|
|
||||||
sound::Sound,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
use dashmap::DashMap;
|
||||||
|
use dotenv::dotenv;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
client::{bridge::gateway::GatewayIntents, Client, Context},
|
client::{bridge::gateway::GatewayIntents, Client, Context},
|
||||||
http::Http,
|
http::Http,
|
||||||
@ -27,19 +23,17 @@ use serenity::{
|
|||||||
},
|
},
|
||||||
prelude::{Mutex, TypeMapKey},
|
prelude::{Mutex, TypeMapKey},
|
||||||
};
|
};
|
||||||
|
|
||||||
use songbird::{create_player, error::JoinResult, tracks::TrackHandle, Call, SerenityInit};
|
use songbird::{create_player, error::JoinResult, tracks::TrackHandle, Call, SerenityInit};
|
||||||
|
|
||||||
use sqlx::mysql::MySqlPool;
|
use sqlx::mysql::MySqlPool;
|
||||||
|
|
||||||
use dotenv::dotenv;
|
|
||||||
|
|
||||||
use dashmap::DashMap;
|
|
||||||
|
|
||||||
use std::{collections::HashMap, env, sync::Arc};
|
|
||||||
|
|
||||||
use tokio::sync::{MutexGuard, RwLock};
|
use tokio::sync::{MutexGuard, RwLock};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
event_handlers::Handler,
|
||||||
|
framework::{Args, RegexFramework},
|
||||||
|
guild_data::{CtxGuildData, GuildData},
|
||||||
|
sound::Sound,
|
||||||
|
};
|
||||||
|
|
||||||
struct MySQL;
|
struct MySQL;
|
||||||
|
|
||||||
impl TypeMapKey for MySQL {
|
impl TypeMapKey for MySQL {
|
||||||
|
17
src/sound.rs
17
src/sound.rs
@ -1,15 +1,12 @@
|
|||||||
use super::error::ErrorTypes;
|
|
||||||
|
|
||||||
use sqlx::mysql::MySqlPool;
|
|
||||||
|
|
||||||
use tokio::{fs::File, io::AsyncWriteExt, process::Command};
|
|
||||||
|
|
||||||
use songbird::input::restartable::Restartable;
|
|
||||||
|
|
||||||
use std::{env, path::Path};
|
use std::{env, path::Path};
|
||||||
|
|
||||||
use crate::{JoinSoundCache, MySQL};
|
|
||||||
use serenity::{async_trait, model::id::UserId, prelude::Context};
|
use serenity::{async_trait, model::id::UserId, prelude::Context};
|
||||||
|
use songbird::input::restartable::Restartable;
|
||||||
|
use sqlx::mysql::MySqlPool;
|
||||||
|
use tokio::{fs::File, io::AsyncWriteExt, process::Command};
|
||||||
|
|
||||||
|
use super::error::ErrorTypes;
|
||||||
|
use crate::{JoinSoundCache, MySQL};
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait JoinSoundCtx {
|
pub trait JoinSoundCtx {
|
||||||
@ -83,7 +80,6 @@ SELECT join_sound_id
|
|||||||
|
|
||||||
let pool = self.data.read().await.get::<MySQL>().cloned().unwrap();
|
let pool = self.data.read().await.get::<MySQL>().cloned().unwrap();
|
||||||
|
|
||||||
if join_sound_cache.get(&user_id).is_none() {
|
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
"
|
"
|
||||||
INSERT IGNORE INTO users (user)
|
INSERT IGNORE INTO users (user)
|
||||||
@ -93,7 +89,6 @@ INSERT IGNORE INTO users (user)
|
|||||||
)
|
)
|
||||||
.execute(&pool)
|
.execute(&pool)
|
||||||
.await;
|
.await;
|
||||||
}
|
|
||||||
|
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
"
|
"
|
||||||
|
Loading…
Reference in New Issue
Block a user