mention for commands

This commit is contained in:
jude-lafitteIII 2020-05-20 15:33:28 +01:00
parent 815600709d
commit 03e3c4f301
4 changed files with 11 additions and 11 deletions

View File

@ -22,4 +22,4 @@ Config options:
* `PATREON_GUILD`- specifies the ID of the guild being used for Patreon benefits
* `PATREON_ROLE`- specifies the role being checked for Patreon benefits
* `CACHING_LOCATION`- specifies the location in which to cache the audio files (defaults to `/tmp/`)
* `CLIENT_ID`- specifies the ID of the client for mention commands

View File

@ -13,7 +13,7 @@ impl GuildData {
let guild = sqlx::query_as!(
GuildData,
"
SELECT *
SELECT id, name, prefix, volume
FROM servers
WHERE id = ?
", guild_id
@ -21,11 +21,8 @@ SELECT *
.fetch_one(&db_pool)
.await;
match guild {
Ok(guild) => Some(guild),
Err(_) => None,
}
guild.ok()
}
pub async fn create_from_guild(guild: Guild, db_pool: MySqlPool) -> Result<GuildData, Box<dyn std::error::Error>> {

View File

@ -28,6 +28,7 @@ use serenity::{
id::{
GuildId,
RoleId,
UserId,
},
voice::VoiceState,
},
@ -296,6 +297,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.allow_dm(false)
.ignore_bots(true)
.ignore_webhooks(true)
.on_mention(env::var("CLIENT_ID")
.and_then(|val| Ok(UserId(val.parse::<u64>().expect("CLIENT_ID not valid")))).ok())
)
.group(&ALLUSERS_GROUP)
.group(&ROLEMANAGEDUSERS_GROUP)
@ -745,7 +748,7 @@ async fn change_public(ctx: &Context, msg: &Message, args: Args) -> CommandResul
match sound_result {
Some(sound) => {
if sound.uploader_id != *uid {
if sound.uploader_id != Some(*uid) {
msg.channel_id.say(&ctx, "You can only change the availability of sounds you have uploaded. Use `?list me` to view your sounds").await?;
}
@ -787,7 +790,7 @@ async fn delete_sound(ctx: &Context, msg: &Message, args: Args) -> CommandResult
match sound_result {
Some(sound) => {
if sound.uploader_id != uid && sound.server_id != gid {
if sound.uploader_id != Some(uid) && sound.server_id != gid {
msg.channel_id.say(&ctx, "You can only delete sounds from this guild or that you have uploaded.").await?;
}
@ -881,9 +884,9 @@ SELECT * FROM sounds
"
)
.fetch_all(&pool)
.await?;
.await.unwrap();
format_search_results(search_results, msg, ctx).await?;
format_search_results(search_results, msg, ctx).await.unwrap();
Ok(())
}

View File

@ -24,7 +24,7 @@ pub struct Sound {
pub plays: u32,
pub public: bool,
pub server_id: u64,
pub uploader_id: u64,
pub uploader_id: Option<u64>,
pub src: Vec<u8>,
}