Skip to content

Commit

Permalink
Add compromised account advice to ban DMs
Browse files Browse the repository at this point in the history
closes #229
  • Loading branch information
Erisa committed Sep 15, 2024
1 parent 1a60926 commit c31a34e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Commands/InteractionCommands/BanInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public async Task BanSlashCommand(InteractionContext ctx,
[Option("reason", "The reason the user is being banned")] string reason,
[Option("keep_messages", "Whether to keep the users messages when banning")] bool keepMessages = false,
[Option("time", "The length of time the user is banned for")] string time = null,
[Option("appeal_link", "Whether to show the user an appeal URL in the DM")] bool appealable = false
[Option("appeal_link", "Whether to show the user an appeal URL in the DM")] bool appealable = false,
[Option("compromised_account", "Whether to include special instructions for compromised accounts")] bool compromisedAccount = false
)
{
// Initial response to avoid the 3 second timeout, will edit later.
Expand Down Expand Up @@ -78,15 +79,15 @@ public async Task BanSlashCommand(InteractionContext ctx,

if (member is null)
{
await BanHelpers.BanFromServerAsync(user.Id, reason, ctx.User.Id, ctx.Guild, messageDeleteDays, ctx.Channel, banDuration, appealable);
await BanFromServerAsync(user.Id, reason, ctx.User.Id, ctx.Guild, messageDeleteDays, ctx.Channel, banDuration, appealable, compromisedAccount);
}
else
{
if (DiscordHelpers.AllowedToMod(ctx.Member, member))
{
if (DiscordHelpers.AllowedToMod(await ctx.Guild.GetMemberAsync(ctx.Client.CurrentUser.Id), member))
{
await BanHelpers.BanFromServerAsync(user.Id, reason, ctx.User.Id, ctx.Guild, messageDeleteDays, ctx.Channel, banDuration, appealable);
await BanFromServerAsync(user.Id, reason, ctx.User.Id, ctx.Guild, messageDeleteDays, ctx.Channel, banDuration, appealable, compromisedAccount);
}
else
{
Expand Down
10 changes: 8 additions & 2 deletions Helpers/BanHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
{
public class BanHelpers
{
public static async Task<bool> BanFromServerAsync(ulong targetUserId, string reason, ulong moderatorId, DiscordGuild guild, int deleteDays = 7, DiscordChannel channel = null, TimeSpan banDuration = default, bool appealable = false)
public static async Task<bool> BanFromServerAsync(ulong targetUserId, string reason, ulong moderatorId, DiscordGuild guild, int deleteDays = 7, DiscordChannel channel = null, TimeSpan banDuration = default, bool appealable = false, bool compromisedAccount = false)
{
bool permaBan = false;
DateTime? actionTime = DateTime.Now;
DateTime? expireTime = actionTime + banDuration;
DiscordMember moderator = await guild.GetMemberAsync(moderatorId);

if (reason.ToLower().Contains("compromised"))
compromisedAccount = true;

if (banDuration == default)
{
permaBan = true;
Expand All @@ -34,7 +37,10 @@ public static async Task<bool> BanFromServerAsync(ulong targetUserId, string rea
{
if (appealable)
{
await targetMember.SendMessageAsync($"{Program.cfgjson.Emoji.Banned} You have been banned from **{guild.Name}**!\nReason: **{reason}**\nYou can appeal the ban here: <{Program.cfgjson.AppealLink}>");
if (compromisedAccount)
await targetMember.SendMessageAsync($"{Program.cfgjson.Emoji.Banned} You have been banned from **{guild.Name}**!\nReason: **{reason}**\nYou can appeal the ban here: <{Program.cfgjson.AppealLink}>\nBefore appealing, please follow these steps to protect your account:\n1. Reset your Discord account password. Even if you use MFA, this will reset all session tokens.\n2. Review active sessions and authorised app connections.\n3. Ensure your PC is free of malware.\n4. [Enable MFA](https://support.discord.com/hc/en-us/articles/219576828-Setting-up-Multi-Factor-Authentication) if not already.");
else
await targetMember.SendMessageAsync($"{Program.cfgjson.Emoji.Banned} You have been banned from **{guild.Name}**!\nReason: **{reason}**\nYou can appeal the ban here: <{Program.cfgjson.AppealLink}>");
}
else
{
Expand Down

0 comments on commit c31a34e

Please sign in to comment.