public async Task PardonAsync(SocketGuildUser User, [Remainder] string Reason = null) { if (!CommandUtils.HasPermission(Context.Guild.GetUser(Context.User.Id), GuildPermission.BanMembers)) { await ReplyAsync("You are missing the permissions to warn other users."); return; } var Guild = FileSystem.GetGuild(Context.Guild); var user = Guild.GuildUsers.Where(x => x.ID == User.Id).First(); if (user.WarnCount == 0) { await ReplyAsync("User doesn't have any warns."); return; } try { await ReplyAsync($"{User.ToString()} has been pardoned and a warn has been removed.\n**Reason**: {Reason ?? "None"}"); Embed modlog = await CommandUtils.CreateModlog(Context.Guild, Context.User, User as SocketUser, CommandUtils.ModlogType.Muted, Reason); await Context.Guild.GetTextChannel(FileSystem.GetGuild(Context.Guild).ModlogChannel.Value).SendMessageAsync("", embed: modlog); } catch (OperationCanceledException e) { return; } catch (Exception e) { await ReplyAsync("Something has gone horribly wrong and the dev has been notified."); await Context.Client.GetUser(config.AuthorId).SendMessageAsync($"ERROR on message from {Context.User.ToString()}:\n{Context.Message.Content}\nThrew error: {e.Message}"); } }
public async Task BanAsync(SocketGuildUser User, [Remainder] string Reason = null) { if (!CommandUtils.HasPermission(Context.Guild.GetUser(Context.User.Id), GuildPermission.BanMembers)) { await ReplyAsync("You are missing the permissions to ban other users."); return; } if (!CommandUtils.HasPermission(Context.Guild.CurrentUser, GuildPermission.BanMembers)) { await ReplyAsync("I am missing the permissions to ban other users."); return; } try { await User.BanAsync(reason : Reason); await ReplyAsync($"{User.ToString()} has been banned from the server.\n**Reason**: {Reason ?? "None"}"); Embed modlog = await CommandUtils.CreateModlog(Context.Guild, Context.User, User as SocketUser, CommandUtils.ModlogType.Ban, Reason); await Context.Guild.GetTextChannel(FileSystem.GetGuild(Context.Guild).ModlogChannel.Value).SendMessageAsync("", embed: modlog); } catch (OperationCanceledException e) { return; } catch (Exception e) { await ReplyAsync("Something has gone horribly wrong and the dev has been notified."); await Context.Client.GetUser(config.AuthorId).SendMessageAsync($"ERROR on message from {Context.User.ToString()}:\n{Context.Message.Content}\nThrew error: {e.Message}"); } }
public async Task MuteAsync(SocketGuildUser User, [Remainder] string Reason = null) { if (!CommandUtils.HasPermission(Context.Guild.GetUser(Context.User.Id), GuildPermission.ManageRoles)) { await ReplyAsync("You are missing the permissions to mute other users."); return; } if (!CommandUtils.HasPermission(Context.Guild.CurrentUser, GuildPermission.ManageRoles)) { await ReplyAsync("I am missing the permissions to mute other users."); return; } var Guild = FileSystem.GetGuild(Context.Guild); if (Guild.MuteRole.Equals(null)) { await ReplyAsync("No role for the mute command assigned.\nUse `//setmuterole <rolename>`to assign a mute role."); return; } if (User.Roles.Where(x => x.Id == Guild.MuteRole.Value).Count() != 0) { await ReplyAsync("User is already muted"); return; } try { await User.AddRoleAsync(Context.Guild.GetRole(Guild.MuteRole.Value)); await ReplyAsync($"{User.ToString()} has been muted.\nTo unmute them, use `//unmute`\n\n**Reason**: {Reason ?? "None"}"); Embed modlog = await CommandUtils.CreateModlog(Context.Guild, Context.User, User as SocketUser, CommandUtils.ModlogType.Muted, Reason); await Context.Guild.GetTextChannel(FileSystem.GetGuild(Context.Guild).ModlogChannel.Value).SendMessageAsync("", embed: modlog); } catch (OperationCanceledException e) { return; } catch (Exception e) { await ReplyAsync("Something has gone horribly wrong and the dev has been notified."); await Context.Client.GetUser(config.AuthorId).SendMessageAsync($"ERROR on message from {Context.User.ToString()}:\n{Context.Message.Content}\nThrew error: {e.Message}"); } }
public async Task WarnAsync(SocketGuildUser User, [Remainder] string Reason = null) { if (!CommandUtils.HasPermission(Context.Guild.GetUser(Context.User.Id), GuildPermission.BanMembers)) { await ReplyAsync("You are missing the permissions to warn other users."); return; } if (!CommandUtils.HasPermissions(Context.Guild.CurrentUser, new GuildPermission[] { GuildPermission.BanMembers, GuildPermission.KickMembers })) { await ReplyAsync("I am missing the permissions to warn other users."); return; } var Guild = FileSystem.GetGuild(Context.Guild); var user = Guild.GuildUsers.Where(x => x.ID == User.Id).First(); if (user.WarnCount + 1 >= Guild.WarnsForAction && Guild.WarnsForAction != 0) { if (Guild.BanForWarns) { try { await User.BanAsync(reason : Reason); await ReplyAsync($"{User.ToString()} has been banned from the server due to reaching the warn limit.\n**Reason**: {Reason ?? "None"}"); Embed modlog = await CommandUtils.CreateModlog(Context.Guild, Context.User, User as SocketUser, CommandUtils.ModlogType.Warn, Reason); await Context.Guild.GetTextChannel(FileSystem.GetGuild(Context.Guild).ModlogChannel.Value).SendMessageAsync("", embed: modlog); Embed modlog2 = await CommandUtils.CreateModlog(Context.Guild, Context.User, User as SocketUser, CommandUtils.ModlogType.Ban, $"{User.ToString()} reached the warn limit and got banned"); await Context.Guild.GetTextChannel(FileSystem.GetGuild(Context.Guild).ModlogChannel.Value).SendMessageAsync("", embed: modlog); } catch (OperationCanceledException e) { return; } catch (Exception e) { await ReplyAsync("Something has gone horribly wrong and the dev has been notified."); await Context.Client.GetUser(config.AuthorId).SendMessageAsync($"ERROR on message from {Context.User.ToString()}:\n{Context.Message.Content}\nThrew error: {e.Message}"); } } else { try { await User.KickAsync(Reason); await ReplyAsync($"{User.ToString()} has been kicked from the server due to reaching the warn limit.\n**Reason**: {Reason ?? "None"}"); Embed modlog = await CommandUtils.CreateModlog(Context.Guild, Context.User, User as SocketUser, CommandUtils.ModlogType.Warn, Reason); await Context.Guild.GetTextChannel(FileSystem.GetGuild(Context.Guild).ModlogChannel.Value).SendMessageAsync("", embed: modlog); Embed modlog2 = await CommandUtils.CreateModlog(Context.Guild, Context.User, User as SocketUser, CommandUtils.ModlogType.Kick, $"{User.ToString()} reached the warn limit and got kicked"); await Context.Guild.GetTextChannel(FileSystem.GetGuild(Context.Guild).ModlogChannel.Value).SendMessageAsync("", embed: modlog); } catch (OperationCanceledException e) { return; } catch (Exception e) { await ReplyAsync("Something has gone horribly wrong and the dev has been notified."); await Context.Client.GetUser(config.AuthorId).SendMessageAsync($"ERROR on message from {Context.User.ToString()}:\n{Context.Message.Content}\nThrew error: {e.Message}"); } } return; } try { await ReplyAsync($"{User.ToString()} has been warned.\nTo remove a warn from them, use `//pardon <user>`\n\n**Reason**: {Reason ?? "None"}"); Embed modlog = await CommandUtils.CreateModlog(Context.Guild, Context.User, User as SocketUser, CommandUtils.ModlogType.Muted, Reason); await Context.Guild.GetTextChannel(FileSystem.GetGuild(Context.Guild).ModlogChannel.Value).SendMessageAsync("", embed: modlog); } catch (OperationCanceledException e) { return; } catch (Exception e) { await ReplyAsync("Something has gone horribly wrong and the dev has been notified."); await Context.Client.GetUser(config.AuthorId).SendMessageAsync($"ERROR on message from {Context.User.ToString()}:\n{Context.Message.Content}\nThrew error: {e.Message}"); } }