Webhook command
Add a command to view the webhook, as some users wish to use the webhook to edit past reminders.
This commit is contained in:
		
							
								
								
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							@@ -2123,7 +2123,7 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "reminder_rs"
 | 
					name = "reminder_rs"
 | 
				
			||||||
version = "1.6.0"
 | 
					version = "1.6.1"
 | 
				
			||||||
dependencies = [
 | 
					dependencies = [
 | 
				
			||||||
 "base64",
 | 
					 "base64",
 | 
				
			||||||
 "chrono",
 | 
					 "chrono",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
[package]
 | 
					[package]
 | 
				
			||||||
name = "reminder_rs"
 | 
					name = "reminder_rs"
 | 
				
			||||||
version = "1.6.0"
 | 
					version = "1.6.1"
 | 
				
			||||||
authors = ["jellywx <judesouthworth@pm.me>"]
 | 
					authors = ["jellywx <judesouthworth@pm.me>"]
 | 
				
			||||||
edition = "2018"
 | 
					edition = "2018"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -124,6 +124,39 @@ You may want to use one of the popular timezones below, otherwise click [here](h
 | 
				
			|||||||
    Ok(())
 | 
					    Ok(())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// View the webhook being used to send reminders to this channel
 | 
				
			||||||
 | 
					#[poise::command(
 | 
				
			||||||
 | 
					    slash_command,
 | 
				
			||||||
 | 
					    identifying_name = "webhook_url",
 | 
				
			||||||
 | 
					    required_permissions = "ADMINISTRATOR"
 | 
				
			||||||
 | 
					)]
 | 
				
			||||||
 | 
					pub async fn webhook(ctx: Context<'_>) -> Result<(), Error> {
 | 
				
			||||||
 | 
					    match ctx.channel_data().await {
 | 
				
			||||||
 | 
					        Ok(data) => {
 | 
				
			||||||
 | 
					            if let (Some(id), Some(token)) = (data.webhook_id, data.webhook_token) {
 | 
				
			||||||
 | 
					                let _ = ctx
 | 
				
			||||||
 | 
					                    .send(|b| {
 | 
				
			||||||
 | 
					                        b.ephemeral(true).content(format!(
 | 
				
			||||||
 | 
					                            "**Warning!**
 | 
				
			||||||
 | 
					This link can be used by users to anonymously send messages, with or without permissions.
 | 
				
			||||||
 | 
					Do not share it!
 | 
				
			||||||
 | 
					|| https://discord.com/api/webhooks/{}/{} ||",
 | 
				
			||||||
 | 
					                            id, token,
 | 
				
			||||||
 | 
					                        ))
 | 
				
			||||||
 | 
					                    })
 | 
				
			||||||
 | 
					                    .await;
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                let _ = ctx.say("No webhook configured on this channel.").await;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        Err(_) => {
 | 
				
			||||||
 | 
					            let _ = ctx.say("No webhook configured on this channel.").await;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Ok(())
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async fn macro_name_autocomplete(ctx: Context<'_>, partial: String) -> Vec<String> {
 | 
					async fn macro_name_autocomplete(ctx: Context<'_>, partial: String) -> Vec<String> {
 | 
				
			||||||
    sqlx::query!(
 | 
					    sqlx::query!(
 | 
				
			||||||
        "
 | 
					        "
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -101,6 +101,7 @@ async fn _main(tx: Sender<()>) -> Result<(), Box<dyn StdError + Send + Sync>> {
 | 
				
			|||||||
            info_cmds::clock_context_menu(),
 | 
					            info_cmds::clock_context_menu(),
 | 
				
			||||||
            info_cmds::dashboard(),
 | 
					            info_cmds::dashboard(),
 | 
				
			||||||
            moderation_cmds::timezone(),
 | 
					            moderation_cmds::timezone(),
 | 
				
			||||||
 | 
					            moderation_cmds::webhook(),
 | 
				
			||||||
            poise::Command {
 | 
					            poise::Command {
 | 
				
			||||||
                subcommands: vec![
 | 
					                subcommands: vec![
 | 
				
			||||||
                    moderation_cmds::delete_macro(),
 | 
					                    moderation_cmds::delete_macro(),
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user