Delete messages posted in the training channel

This commit is contained in:
Joseph Ferano 2022-04-02 15:15:39 +07:00
parent f25b495089
commit b6e45bd1d9
2 changed files with 11 additions and 2 deletions

View File

@ -59,6 +59,7 @@ inviterCommands.RegisterCommands<InviteTracker.Inviter>(guild);
//sc3.RegisterCommands<SlotMachine>(guild);
hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent))
hackerBattleBot.add_MessageCreated(AsyncEventHandler(HackerBattle.handleMessageCreated))
storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleStoreEvents))
stealBot.add_ComponentInteractionCreated(AsyncEventHandler(Thief.handleStealButton))
inviterBot.add_GuildMemberAdded(AsyncEventHandler(InviteTracker.handleGuildMemberAdded))
@ -81,9 +82,9 @@ let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEven
:> Task
//hackerBattleBot.add_InteractionCreated(AsyncEventHandler(asdf))
if guild <> 922419263275425832uL then
//if guild <> 922419263275425832uL then
// Trainer.sendInitialEmbed hackerBattleBot
InviteTracker.sendInitialEmbed inviterBot
// InviteTracker.sendInitialEmbed inviterBot
hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser

View File

@ -256,6 +256,14 @@ let handleButtonEvent (_ : DiscordClient) (event : ComponentInteractionCreateEve
do! eventCtx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask
}
let handleMessageCreated (_ : DiscordClient) (event : MessageCreateEventArgs) =
task {
if event.Channel.Id = GuildEnvironment.channelTraining && event.Author.Id <> GuildEnvironment.botIdHackerBattle then
do! Async.Sleep 1000
do! event.Message.DeleteAsync()
} :> Task
type HackerGame() =
inherit ApplicationCommandModule ()