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 crate::{
|
||||
framework::{Args, CommandInvoke, CreateGenericResponse, RegexFramework},
|
||||
framework::{Args, CommandInvoke, CommandKind, CreateGenericResponse, RegexFramework},
|
||||
THEME_COLOR,
|
||||
};
|
||||
|
||||
use crate::framework::CommandKind;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
#[command]
|
||||
#[group("Information")]
|
||||
#[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::{
|
||||
client::Context,
|
||||
framework::standard::CommandResult,
|
||||
@ -12,8 +13,6 @@ use crate::{
|
||||
MySQL, MAX_SOUNDS, PATREON_GUILD, PATREON_ROLE,
|
||||
};
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
#[command("upload")]
|
||||
#[group("Manage")]
|
||||
#[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::{
|
||||
builder::CreateActionRow,
|
||||
client::Context,
|
||||
framework::standard::CommandResult,
|
||||
model::interactions::{message_component::ButtonStyle, InteractionResponseType},
|
||||
};
|
||||
|
||||
use songbird::{
|
||||
create_player, ffmpeg,
|
||||
input::{cached::Memory, Input},
|
||||
@ -22,8 +22,6 @@ use crate::{
|
||||
AudioIndex, MySQL,
|
||||
};
|
||||
|
||||
use std::{convert::TryFrom, time::Duration};
|
||||
|
||||
#[command]
|
||||
#[aliases("p")]
|
||||
#[required_permissions(Managed)]
|
||||
|
@ -1,5 +1,4 @@
|
||||
use regex_command_attr::command;
|
||||
|
||||
use serenity::{client::Context, framework::standard::CommandResult};
|
||||
|
||||
use crate::{
|
||||
|
@ -1,5 +1,4 @@
|
||||
use regex_command_attr::command;
|
||||
|
||||
use serenity::{client::Context, framework::standard::CommandResult};
|
||||
|
||||
use crate::{
|
||||
|
@ -1,11 +1,9 @@
|
||||
use regex_command_attr::command;
|
||||
|
||||
use serenity::{client::Context, framework::standard::CommandResult};
|
||||
use songbird;
|
||||
|
||||
use crate::framework::{Args, CommandInvoke, CreateGenericResponse};
|
||||
|
||||
use songbird;
|
||||
|
||||
#[command("stop")]
|
||||
#[required_permissions(Managed)]
|
||||
#[group("Stop")]
|
||||
|
@ -1,10 +1,4 @@
|
||||
use crate::{
|
||||
framework::RegexFramework,
|
||||
guild_data::CtxGuildData,
|
||||
join_channel, play_audio, play_from_query,
|
||||
sound::{JoinSoundCtx, Sound},
|
||||
MySQL, ReqwestClient,
|
||||
};
|
||||
use std::{collections::HashMap, env};
|
||||
|
||||
use serenity::{
|
||||
async_trait,
|
||||
@ -19,12 +13,15 @@ use serenity::{
|
||||
},
|
||||
utils::shard_id,
|
||||
};
|
||||
|
||||
use songbird::{Event, EventContext, EventHandler as SongbirdEventHandler};
|
||||
|
||||
use crate::framework::Args;
|
||||
|
||||
use std::{collections::HashMap, env};
|
||||
use crate::{
|
||||
framework::{Args, RegexFramework},
|
||||
guild_data::CtxGuildData,
|
||||
join_channel, play_audio, play_from_query,
|
||||
sound::{JoinSoundCtx, Sound},
|
||||
MySQL, ReqwestClient,
|
||||
};
|
||||
|
||||
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::{
|
||||
async_trait,
|
||||
builder::CreateEmbed,
|
||||
builder::{CreateComponents, CreateEmbed},
|
||||
cache::Cache,
|
||||
client::Context,
|
||||
framework::{standard::CommandResult, Framework},
|
||||
@ -9,7 +19,7 @@ use serenity::{
|
||||
model::{
|
||||
channel::{Channel, GuildChannel, Message},
|
||||
guild::{Guild, Member},
|
||||
id::{ChannelId, GuildId, UserId},
|
||||
id::{ChannelId, GuildId, RoleId, UserId},
|
||||
interactions::{
|
||||
application_command::{
|
||||
ApplicationCommand, ApplicationCommandInteraction, ApplicationCommandOptionType,
|
||||
@ -21,21 +31,7 @@ use serenity::{
|
||||
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 serde_json::Value;
|
||||
use serenity::builder::CreateComponents;
|
||||
use serenity::model::id::RoleId;
|
||||
|
||||
type CommandFn = for<'fut> fn(
|
||||
&'fut Context,
|
||||
|
@ -1,9 +1,11 @@
|
||||
use crate::{GuildDataCache, MySQL};
|
||||
use std::sync::Arc;
|
||||
|
||||
use serenity::{async_trait, model::id::GuildId, prelude::Context};
|
||||
use sqlx::mysql::MySqlPool;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::{GuildDataCache, MySQL};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct GuildData {
|
||||
pub id: u64,
|
||||
|
26
src/main.rs
26
src/main.rs
@ -8,15 +8,11 @@ mod framework;
|
||||
mod guild_data;
|
||||
mod sound;
|
||||
|
||||
use crate::{
|
||||
event_handlers::Handler,
|
||||
framework::{Args, RegexFramework},
|
||||
guild_data::{CtxGuildData, GuildData},
|
||||
sound::Sound,
|
||||
};
|
||||
use std::{collections::HashMap, env, sync::Arc};
|
||||
|
||||
use dashmap::DashMap;
|
||||
use dotenv::dotenv;
|
||||
use log::info;
|
||||
|
||||
use serenity::{
|
||||
client::{bridge::gateway::GatewayIntents, Client, Context},
|
||||
http::Http,
|
||||
@ -27,19 +23,17 @@ use serenity::{
|
||||
},
|
||||
prelude::{Mutex, TypeMapKey},
|
||||
};
|
||||
|
||||
use songbird::{create_player, error::JoinResult, tracks::TrackHandle, Call, SerenityInit};
|
||||
|
||||
use sqlx::mysql::MySqlPool;
|
||||
|
||||
use dotenv::dotenv;
|
||||
|
||||
use dashmap::DashMap;
|
||||
|
||||
use std::{collections::HashMap, env, sync::Arc};
|
||||
|
||||
use tokio::sync::{MutexGuard, RwLock};
|
||||
|
||||
use crate::{
|
||||
event_handlers::Handler,
|
||||
framework::{Args, RegexFramework},
|
||||
guild_data::{CtxGuildData, GuildData},
|
||||
sound::Sound,
|
||||
};
|
||||
|
||||
struct MySQL;
|
||||
|
||||
impl TypeMapKey for MySQL {
|
||||
|
29
src/sound.rs
29
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 crate::{JoinSoundCache, MySQL};
|
||||
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]
|
||||
pub trait JoinSoundCtx {
|
||||
@ -83,17 +80,15 @@ SELECT join_sound_id
|
||||
|
||||
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)
|
||||
VALUES (?)
|
||||
",
|
||||
user_id.as_u64()
|
||||
)
|
||||
.execute(&pool)
|
||||
.await;
|
||||
}
|
||||
user_id.as_u64()
|
||||
)
|
||||
.execute(&pool)
|
||||
.await;
|
||||
|
||||
let _ = sqlx::query!(
|
||||
"
|
||||
|
Loading…
Reference in New Issue
Block a user