From fe5086f6facf749bc72471cdb551028b4e4ac618 Mon Sep 17 00:00:00 2001 From: Th0mk Date: Fri, 13 Dec 2024 16:16:00 +0900 Subject: [PATCH] fix remove not always working --- .../SlashCommands/UserSlashCommands.cs | 35 +++++++++++++++---- src/FMBot.Bot/TextCommands/UserCommands.cs | 13 +++++-- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/FMBot.Bot/SlashCommands/UserSlashCommands.cs b/src/FMBot.Bot/SlashCommands/UserSlashCommands.cs index 44349ce5..c5f53dd8 100644 --- a/src/FMBot.Bot/SlashCommands/UserSlashCommands.cs +++ b/src/FMBot.Bot/SlashCommands/UserSlashCommands.cs @@ -220,9 +220,15 @@ public async Task GetUserSetting(string[] inputs) } case UserSetting.DeleteAccount: { - response = UserBuilder.RemoveDataResponse(new ContextModel(this.Context, contextUser)); + var serverEmbed = new EmbedBuilder() + .WithColor(DiscordConstants.WarningColorOrange) + .WithDescription("Check your DMs to continue with your .fmbot account deletion."); - await this.Context.SendResponse(this.Interactivity, response, ephemeral: true); + await this.Context.Interaction.RespondAsync("", embed: serverEmbed.Build(), ephemeral: true); + + response = UserBuilder.RemoveDataResponse(new ContextModel(this.Context, contextUser)); + await this.Context.User.SendMessageAsync("", false, response.Embed.Build(), + components: response.Components.Build()); break; } default: @@ -323,7 +329,6 @@ await FollowupAsync(null, [loginSuccessResponse.Embed.Build()], ephemeral: true, } } - [SlashCommand("privacy", "Changes your visibility to other .fmbot users in Global WhoKnows")] [UsernameSetRequired] [CommandContextType(InteractionContextType.BotDm, InteractionContextType.PrivateChannel, @@ -419,7 +424,8 @@ await this._adminService.GetFilteredUserAsync(userSettings.UserNameLastFM, "We automatically moderate global leaderboards to keep them fun and fair for everybody. Remember, it's just a few numbers on a list."); globalStatus.AppendLine(); - globalStatus.AppendLine(".fmbot is not affiliated with Last.fm. This filter only applies to global charts in .fmbot."); + globalStatus.AppendLine( + ".fmbot is not affiliated with Last.fm. This filter only applies to global charts in .fmbot."); } if (globalStatus.Length > 0) @@ -697,9 +703,26 @@ public async Task RemoveAsync() { var userSettings = await this._userService.GetFullUserAsync(this.Context.User.Id); - var response = UserBuilder.RemoveDataResponse(new ContextModel(this.Context, userSettings)); + if (this.Context.Guild != null) + { + var serverEmbed = new EmbedBuilder() + .WithColor(DiscordConstants.WarningColorOrange) + .WithDescription("Check your DMs to continue with your .fmbot account deletion."); - await this.Context.SendResponse(this.Interactivity, response, ephemeral: true); + await this.Context.Interaction.RespondAsync("", embed: serverEmbed.Build(), ephemeral: true); + } + else + { + var serverEmbed = new EmbedBuilder() + .WithColor(DiscordConstants.WarningColorOrange) + .WithDescription("Check the message below to continue with your .fmbot account deletion."); + + await this.Context.Interaction.RespondAsync("", embed: serverEmbed.Build(), ephemeral: true); + } + + var response = UserBuilder.RemoveDataResponse(new ContextModel(this.Context, userSettings)); + await this.Context.User.SendMessageAsync("", false, response.Embed.Build(), + components: response.Components.Build()); this.Context.LogCommandUsed(response.CommandResponse); } diff --git a/src/FMBot.Bot/TextCommands/UserCommands.cs b/src/FMBot.Bot/TextCommands/UserCommands.cs index 26fff25c..7b98980a 100644 --- a/src/FMBot.Bot/TextCommands/UserCommands.cs +++ b/src/FMBot.Bot/TextCommands/UserCommands.cs @@ -695,9 +695,18 @@ public async Task RemoveAsync([Remainder] string confirmation = null) return; } - var response = UserBuilder.RemoveDataResponse(new ContextModel(this.Context, prfx, contextUser)); - await this.Context.SendResponse(this.Interactivity, response); + if (this.Context.Guild != null) + { + var serverEmbed = new EmbedBuilder() + .WithColor(DiscordConstants.WarningColorOrange) + .WithDescription("Check your DMs to continue with your .fmbot account deletion."); + + await ReplyAsync(embed: serverEmbed.Build()); + } + + var response = UserBuilder.RemoveDataResponse(new ContextModel(this.Context, prfx, contextUser)); + await this.Context.User.SendMessageAsync("", false, response.Embed.Build(), components: response.Components.Build()); this.Context.LogCommandUsed(response.CommandResponse); } }