Skip to content

Commit

Permalink
fix remove not always working
Browse files Browse the repository at this point in the history
  • Loading branch information
th0mk committed Dec 13, 2024
1 parent 696155c commit fe5086f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
35 changes: 29 additions & 6 deletions src/FMBot.Bot/SlashCommands/UserSlashCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}

Expand Down
13 changes: 11 additions & 2 deletions src/FMBot.Bot/TextCommands/UserCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit fe5086f

Please sign in to comment.