private async Task NewGuildMessage(SocketGuild guild) { var config = Path.Combine(AppContext.BaseDirectory + $"setup/server/{guild.Id}.json"); if (!File.Exists(config)) { GuildConfig.Setup(guild); } await guild.DefaultChannel.SendMessageAsync( $"Hi, I'm PassiveBOT. To see a list of my commands type `{Load.Pre}help` and for some statistics about me type `{Load.Pre}info`\n" + "I am able to do tags, moderation, memes & more!!!!!"); try { var DblApi = new DiscordNetDblApi(client, Tokens.Load().DiscordBotsListToken); var me = await DblApi.GetMeAsync(); await me.UpdateStatsAsync(client.Guilds.Count); } catch { // } }
public async Task Bans() { var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json"); if (!File.Exists(file)) { GuildConfig.Setup(Context.Guild); } var embed = new EmbedBuilder(); embed.WithTitle("Bans"); var config = GuildConfig.GetServer(Context.Guild); var groupedlist = config.Banning.GroupBy(x => x.UserId) .Select(group => new { UserId = group.Key, List = group.ToList() }) .ToList(); foreach (var group in groupedlist) { string username; try { var user = await Context.Guild.GetUserAsync(group.UserId); username = user.Username; } catch { username = group.List.First().User; } var list = ""; foreach (var x in group.List) { if (list.Length >= 800) { embed.AddField($"{username} [{group.UserId}]", list); list = ""; } var moderator = $"{x.Moderator} ".Substring(0, 20); list += $"Mod: {moderator} || Reason: {x.Reason}\n"; } embed.AddField($"{username} [{group.UserId}]", list); } if (embed.Fields.Count > 0) { await ReplyAsync("", false, embed.Build()); } else { await ReplyAsync("There are no bans in the server..."); } }
public async Task ResetKick() { var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json"); if (!File.Exists(file)) { GuildConfig.Setup(Context.Guild); } var config = GuildConfig.GetServer(Context.Guild); config.Kicking = new List <GuildConfig.Kicks>(); GuildConfig.SaveServer(config, Context.Guild); await ReplyAsync($"All server kicks have been cleared."); }
public async Task NewGuildMessage(SocketGuild guild) { //if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, $"setup/server/{guild.Id}/music/"))) // Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, $"setup/server/{guild.Id}/music/")); var config = Path.Combine(AppContext.BaseDirectory + $"setup/server/{guild.Id}.json"); if (!File.Exists(config)) { GuildConfig.Setup(guild); } await guild.DefaultChannel.SendMessageAsync( $"Hi, I'm PassiveBOT. To see a list of my commands type `{Load.Pre}help` and for some statistics about me type `{Load.Pre}info`\n" + "I am able to do music, tags, moderation, memes & more!!!!!"); }
public async Task WarnUser(SocketGuildUser user, [Remainder] string reason = null) { var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json"); if (!File.Exists(file)) { GuildConfig.Setup(Context.Guild); } var embed = new EmbedBuilder(); if (reason == null) { embed.AddField("Error", "Please Specify a reason for warning the user, ie\n" + "`.warn @noobnoob being a noob"); await ReplyAsync("", false, embed.Build()); return; } var config = GuildConfig.GetServer(Context.Guild); var add = new GuildConfig.Warns { Moderator = Context.User.Username, Reason = reason, User = user.Username, UserId = user.Id }; try { await user.SendMessageAsync($"You have been warned in {Context.Guild.Name} for:\n" + $"`{reason}`"); } catch { // } config.Warnings.Add(add); GuildConfig.SaveServer(config, Context.Guild); embed.AddField("User Warned", $"User: {user.Username}\n" + $"UserID: {user.Id}\n" + $"Moderator: {Context.User.Username}\n" + $"Reason: {reason}"); await ReplyAsync("", false, embed.Build()); }
public async Task ClearKick(SocketGuildUser removeuser) { var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json"); if (!File.Exists(file)) { GuildConfig.Setup(Context.Guild); } var embed = new EmbedBuilder(); embed.WithTitle("Kicks Removed"); var config = GuildConfig.GetServer(Context.Guild); var list = ""; var newconfig = new List <GuildConfig.Kicks>(); foreach (var group in config.Kicking) { if (group.UserId == removeuser.Id) { var moderator = $"{group.Moderator} ".Substring(0, 20); list += $"Mod: {moderator} || Reason: {group.Reason}\n"; //config.Kicking.Remove(group); } else { newconfig.Add(group); } } embed.WithDescription(list); config.Kicking = newconfig; GuildConfig.SaveServer(config, Context.Guild); await ReplyAsync($"Kicks for the user {removeuser} have been cleared"); try { await ReplyAsync("", false, embed.Build()); } catch { // } }
public async Task Setup(int i = 0) { if (i == 0) { await ReplyAsync("```\n" + "Reply with the command you would like to perform\n" + "[1] Initialise the config file\n" + "[2] Read the config file\n" + "[3] Delete the config file\n" + "" + "```"); return; } if (i == 1) { GuildConfig.Setup(Context.Guild); await ServerSetup(); } else if (i == 2) { await ServerSetup(); } else if (i == 3) { var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json"); if (File.Exists(file)) { File.Delete(file); await ReplyAsync("The config file has been deleted."); } else { await ReplyAsync("The config file does not exist, please use option 1 to initialise it"); } } else { await ReplyAsync( "Please only reply with the character of your option ie. if you picked 2, reply with just `2`"); } }
public async Task UndoMentionExcempt(IRole role = null) { var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json"); if (!File.Exists(file)) { GuildConfig.Setup(Context.Guild); } var config = GuildConfig.GetServer(Context.Guild); if (role == null) { var embed = new EmbedBuilder(); foreach (var r in config.MentionallExcempt) { try { var rol = Context.Guild.GetRole(r); embed.Description += $"{rol.Name}\n"; } catch { // } } embed.Title = "Roles Excempt from Mention Blocker"; await ReplyAsync("", false, embed.Build()); return; } config.MentionallExcempt.Remove(role.Id); GuildConfig.SaveServer(config, Context.Guild); await ReplyAsync($"{role.Mention} has been removed from those excempt from the Mention Blocker"); }
public async Task Kickuser(SocketGuildUser user, [Remainder] string reason = null) { var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json"); if (!File.Exists(file)) { GuildConfig.Setup(Context.Guild); } var embed = new EmbedBuilder(); if (user.GuildPermissions.Administrator || user.GuildPermissions.KickMembers) { embed.AddField("User Kick Failed", $"This user is an administrator or has the ability to kick other users"); await ReplyAsync("", false, embed.Build()); return; } if (reason == null) { embed.AddField("Error", "Please Specify a reason for kicking the user, ie\n" + "`.kick @noobnoob being a noob"); await ReplyAsync("", false, embed.Build()); return; } var config = GuildConfig.GetServer(Context.Guild); var add = new GuildConfig.Kicks { Moderator = Context.User.Username, Reason = reason, User = user.Username, UserId = user.Id }; try { await user.KickAsync(); } catch { embed.AddField("User Kick Failed", $"This user was unable to be kicked"); await ReplyAsync("", false, embed.Build()); return; } config.Kicking.Add(add); GuildConfig.SaveServer(config, Context.Guild); embed.AddField("User Kicked", $"User: {user.Username}\n" + $"UserID: {user.Id}\n" + $"Moderator: {Context.User.Username}\n" + $"Reason: {reason}"); await ReplyAsync("", false, embed.Build()); }
public async Task BanUser(SocketGuildUser user, [Remainder] string reason = null) { var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json"); if (!File.Exists(file)) { GuildConfig.Setup(Context.Guild); } var embed = new EmbedBuilder(); if (reason == null) { embed.AddField("Error", "Please Specify a reason for banning the user, ie\n" + "`.ban @noobnoob being a noob"); await ReplyAsync("", false, embed.Build()); return; } var config = GuildConfig.GetServer(Context.Guild); var add = new GuildConfig.Bans { Moderator = Context.User.Username, Reason = reason, User = user.Username, UserId = user.Id }; if (user.GuildPermissions.Administrator || user.GuildPermissions.BanMembers) { embed.AddField("User Ban Failed", $"This user is an administrator or has the ability to ban other users"); await ReplyAsync("", false, embed.Build()); return; } try { await user.SendMessageAsync($"You have been banned from {Context.Guild.Name} for:\n" + $"`{reason}`"); await Context.Guild.AddBanAsync(user); } catch { embed.AddField("User Ban Failed", $"This user was unable to be banned"); await ReplyAsync("", false, embed.Build()); return; } config.Banning.Add(add); GuildConfig.SaveServer(config, Context.Guild); embed.AddField("User Banned", $"User: {user.Username}\n" + $"UserID: {user.Id}\n" + $"Moderator: {Context.User.Username}\n" + $"Reason: {reason}"); await ReplyAsync("", false, embed.Build()); }