-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bot] Add shutdown and commit commands
- Loading branch information
1 parent
ad86f72
commit d72157d
Showing
6 changed files
with
81 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Discord.WebSocket; | ||
using Hyperstellar.Sql; | ||
|
||
namespace Hyperstellar.Dc; | ||
|
||
internal class CmdHandlers | ||
Check warning on line 6 in Bot/Dc/CmdHandlers.cs GitHub Actions / inspect
Check warning on line 6 in Bot/Dc/CmdHandlers.cs GitHub Actions / build
|
||
{ | ||
internal static async Task ShutdownAsync(SocketSlashCommand cmd) | ||
{ | ||
if (cmd.User.Id != 264756129916125184) | ||
{ | ||
return; | ||
} | ||
|
||
bool commit = cmd.Data.Options.Count == 0 || (bool)cmd.Data.Options.First().Value; | ||
await cmd.RespondAsync("Ok", ephemeral: true); | ||
if (commit) | ||
{ | ||
Db.Commit(); | ||
} | ||
Environment.Exit(0); | ||
} | ||
|
||
internal static async Task CommitAsync(SocketSlashCommand cmd) | ||
{ | ||
if (cmd.User.Id != 264756129916125184) | ||
{ | ||
return; | ||
} | ||
|
||
Db.Commit(); | ||
await cmd.RespondAsync("Committed", ephemeral: true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters