private async void ExploitDetection_FakeMuteExploitDetected(AbuseTracker _, DiscordUser user) { if (user is null) { await Logger.Error("Log Channel", "User who attempted exploit is somehow null; cannot continue logging."); return; } var logChannel = await client.GetChannelAsync(logChannelID); if (logChannel is null) { await Logger.Error("Log Channel", "Logging channel is null; cannot continue logging."); return; } var embed = new DiscordEmbedBuilder() .WithTitle("🔊 Fake Mute/Deaf Exploit Detected") .WithAuthor($"{user.Username}#{user.Discriminator} [{user.Id}]", null, user.GetAvatarUrl(ImageFormat.Auto)) .WithColor(new DiscordColor(config.LogChannelEmbedColor)) .WithFooter(logChannel.Guild?.Name ?? "null (hmmm - this shouldn't happen)") .WithTimestamp(DateTime.Now) .AddField("Voice Channel", $"<#{config.ChannelID}>", true) .AddField("Action Taken", config.BanDetectedUsers ? "This user was banned." : "No action taken.", true) .Build(); await logChannel.SendMessageAsync(embed); }
private async void Detection_FakeMuteExploitDetected(AbuseTracker detectedUser, DiscordUser user) { if (!resetTask?.IsCompleted ?? false) { return; } await Logger.Warning("Exploit", $"Detected {detectedUser.UserID} speaking while muted for {(DateTime.Now - detectedUser.FirstHit)?.TotalSeconds} seconds."); // We put this on its own thread since it shouldn't interrupt any of this code resetTask = Task.Run(async() => await Cooldown(detectedUser)); if (!config.BanDetectedUsers) { return; } var member = await guild.GetMemberAsync(detectedUser.UserID); try { await member.SendMessageAsync($"You have been banned from {guild.Name} because you were detected using a voice chat exploit.\n\n" + "If you believe this is an error, please contact the server administrators."); } catch (Exception e) { await Logger.Warning("Exploit", $"Unable to send a DM to {member.DisplayName}#{member.Discriminator} [{detectedUser.UserID}]: {e.Message}"); } try { await guild.BanMemberAsync(member, 0, $"{client.CurrentUser.Username}: Detected abuse of the Fake Mute exploit"); } catch (Exception e) { await Logger.Error("Exploit", $"Unable to ban {member.DisplayName}#{member.Discriminator} [{detectedUser.UserID}]: {e.Message}"); } }
private static async Task Cooldown(AbuseTracker detectedUser) { await Task.Delay(1000); detectedUser.Reset(); }