From af46ea6386f01c85cf4a72fade0bac3f48736088 Mon Sep 17 00:00:00 2001 From: shibedrill <53824200+shibedrill@users.noreply.github.com> Date: Mon, 22 Apr 2024 22:12:34 -0400 Subject: [PATCH] help me --- settings.json | 78 +------------------------------------------- src/command/devel.rs | 15 ++++++++- src/main.rs | 3 +- 3 files changed, 17 insertions(+), 79 deletions(-) diff --git a/settings.json b/settings.json index 6b3d635..8b440c5 100644 --- a/settings.json +++ b/settings.json @@ -1,79 +1,3 @@ { - "channels": [ - { - "id": "1030714032900030466", - "bitrate": null, - "parent_id": "1030714032900030464", - "guild_id": "1030714031880818729", - "type": 0, - "owner_id": null, - "last_message_id": "1232079362921332746", - "last_pin_timestamp": null, - "name": "general", - "permission_overwrites": [ - { - "allow": "49152", - "deny": "0", - "id": "1030714031880818729", - "type": 0 - } - ], - "position": 0, - "topic": null, - "user_limit": null, - "nsfw": false, - "rate_limit_per_user": 0, - "rtc_region": null, - "video_quality_mode": null, - "message_count": null, - "member_count": null, - "thread_metadata": null, - "member": null, - "default_auto_archive_duration": null, - "permissions": null, - "flags": 0, - "total_message_sent": null, - "available_tags": [], - "applied_tags": [], - "default_reaction_emoji": null, - "default_thread_rate_limit_per_user": null, - "status": null, - "default_sort_order": null, - "default_forum_layout": null - }, - { - "id": "1232064459737010247", - "bitrate": null, - "parent_id": "1030714032900030464", - "guild_id": "1030714031880818729", - "type": 0, - "owner_id": null, - "last_message_id": null, - "last_pin_timestamp": null, - "name": "asdf", - "permission_overwrites": [], - "position": 2, - "topic": null, - "user_limit": null, - "nsfw": false, - "rate_limit_per_user": 0, - "rtc_region": null, - "video_quality_mode": null, - "message_count": null, - "member_count": null, - "thread_metadata": null, - "member": null, - "default_auto_archive_duration": null, - "permissions": null, - "flags": 0, - "total_message_sent": null, - "available_tags": [], - "applied_tags": [], - "default_reaction_emoji": null, - "default_thread_rate_limit_per_user": null, - "status": null, - "default_sort_order": null, - "default_forum_layout": null - } - ] + "channels": [] } \ No newline at end of file diff --git a/src/command/devel.rs b/src/command/devel.rs index 9c517e3..9b99a09 100644 --- a/src/command/devel.rs +++ b/src/command/devel.rs @@ -1,11 +1,24 @@ use crate::Context; use crate::Error; +/// Shut down the bot remotely #[poise::command(slash_command, owners_only, hide_in_help)] pub async fn shutdown(ctx: Context<'_>) -> Result<(), Error> { ctx.defer_ephemeral().await?; ctx.say("Shutting down...").await?; - info!("Received `shutdown` command, shutting down all shards"); ctx.framework().shard_manager().shutdown_all().await; + info!("Executed command `shutdown` successfully"); + Ok(()) +} + +/// Restart the bot remotely +#[poise::command(slash_command, owners_only, hide_in_help)] +pub async fn restart(ctx: Context<'_>) -> Result<(), Error> { + ctx.defer_ephemeral().await?; + ctx.say("Restarting...").await?; + for shard in ctx.framework().shard_manager().shards_instantiated().await { + ctx.framework().shard_manager().restart(shard).await; + } + info!("Executed command `restart` successfully"); Ok(()) } diff --git a/src/main.rs b/src/main.rs index 6d5aaa7..81dfc22 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,7 +74,7 @@ async fn main() { // +---------------------------------------------------------+ // | ADD COMMANDS HERE | // +---------------------------------------------------------+ - commands: vec![age(), info(), add_channel(), list_channels(), shutdown()], + commands: vec![age(), info(), add_channel(), list_channels(), shutdown(), restart()], initialize_owners: true, ..Default::default() }) @@ -112,4 +112,5 @@ async fn main() { // Finally start everything. Nothing after this should be reachable normally. info!("Starting client"); client.start().await.unwrap(); + info!("All tasks finished, shutting down"); }