public async Task Purge([Remainder] int del = 0) { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile if (guildProfile.PurgeModule) { if (del != 100) { var embed = new EmbedBuilder(); embed.WithColor(new Color(222, 77, 156)); if (del != 0) { var messages = await(Context.Channel as ITextChannel).GetMessagesAsync(del + 1).FlattenAsync(); await(Context.Channel as ITextChannel).DeleteMessagesAsync(messages); } else { embed.AddField("Purge", $"**{Context.User.Username}** Invalid command syntax. Usage => `{guildProfile.CmdPrefix}purge [--amount]`"); await ReplyAsync("", false, embed.Build()); } } } }
// Create the help information inside the EmbedBuilder public void LoadHelp() { var gp = GuildProfiles.GetAccount(Context.Guild); string prefix = gp.CmdPrefix; embed.WithDescription("Nico Nico Nii~ Here is a list of all the commands I can do~"); embed.WithColor(new Color(255, 73, 167)); embed.WithAuthor(author => { author .WithName("Yazawa Nico's Commands") .WithUrl("https://discord.gg/uWRCmkE") .WithIconUrl(Context.Client.CurrentUser.GetAvatarUrl()); }); embed.WithFooter(footer => { footer .WithText($"Requested by {Context.User.Username}#{Context.User.Discriminator} on {DateTime.Now.ToLongDateString()} at {DateTime.Now.ToShortTimeString()}") .WithIconUrl(Context.Client.GetUser(Context.User.Id).GetAvatarUrl()); }); embed.AddField("Prefix", $"{prefix}", true); embed.AddField("Community Server", $"[Community Server](https://discord.gg/uWRCmkE)", true); embed.AddField("Version", $"`v2.1.0`", true); embed.AddField("Core", "`help`, `helpdm`"); embed.AddField("Images", "`angry`, `bad`, `badass`, `bite`, `blush`, `congrats`, `cry`, `cuddle`, `evil`, `excited`, `highfive`, `hug`, `kiss`, `laugh`, `lewd`, `lick`, `niconii`, `no`, `nosebleed`, `pat`, `peek`, `poke`, `sad`, `scared`, `slap`, `sleepy`, `tantrum`, `washi`, `wasted`, `wow`, `yes`"); embed.AddField("Currency", "`daily`, `profile`, `send`"); embed.AddField("Fun", "`choose`, `cucumber`, `divorce`, `give`, `marry`, `notice`, `rip`, `say`, `senpai` `wisdom`"); embed.AddField("Games", "`8ball`, `rps`"); embed.AddField("Moderation", "`ban`, `ban disable`, `ban enable`, `greetmsg disable`, `greetmsg enable`, `greetmsg setchannel`, `greetmsg settext`, `kick`, `kick disable`, `kick enable`, `leavemsg disable`, `leavemsg enable`, `leavemsg setchannel`, `leavemsg settext`, `levelmsg disable`, `levelmsg enable`, `purge`, `purgeu`, `setprefix`, `warn`, `warn disable`, `warn enable`"); embed.AddField("Info", "`afk`, `avatar`, `botinfo`, `userinfo`, `serverinfo`"); embed.AddField("Examples", "`!help [command]` for detailed information on the command."); }
internal static async void UserSentMessage(SocketGuildUser user, SocketTextChannel channel) { var userProfile = UserProfiles.UserProfiles.GetAccount(user); uint oldLevel = userProfile.LevelNumber; userProfile.XP += 1; UserProfiles.UserProfiles.SaveProfiles(); uint newLevel = userProfile.LevelNumber; if (oldLevel != userProfile.LevelNumber) { SocketGuild target = null; target = user.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile if (guildProfile.LevelModule) { // The user leveled up var embed = new EmbedBuilder(); embed.WithColor(255, 73, 167); embed.WithTitle("LEVEL UP!!!"); embed.WithDescription($"{user.Username} just leveled up to **{newLevel}**!"); await channel.SendMessageAsync($"{user.Username} just leveled up to **{newLevel}**"); } } /* * // If the user has a timeout, ignore them * var pf = UserProfiles.UserProfiles.GetAccount(user); * //Console.WriteLine("Leveling: " + pf.dailyB.ToString()); * if (pf.dailyB) * { * //Console.WriteLine("Leveling: " + pf.dailyB.ToString()); * RepeatingTimer.socketUsr = user; * await RepeatingTimer.StartTimer(); * var userProfile = UserProfiles.UserProfiles.GetAccount(user); * uint oldLevel = userProfile.LevelNumber; * userProfile.XP += 10; * UserProfiles.UserProfiles.SaveProfiles(); * uint newLevel = userProfile.LevelNumber; * * if (oldLevel != userProfile.LevelNumber) * { * // The user leveled up * var embed = new EmbedBuilder(); * embed.WithColor(255,73,167); * embed.WithTitle("LEVEL UP!!!"); * embed.WithDescription($"{user.Username} just leveled up to **{newLevel}**!"); * * await channel.SendMessageAsync("", embed: embed.Build()); * * } * pf.dailyB = false; * //Console.WriteLine("Leveling: " + pf.dailyB.ToString()); * UserProfiles.UserProfiles.SaveProfiles(); * } */ }
public async Task ClearWarning(IGuildUser user) { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; string guildId = Context.Guild.Id.ToString(); // Guild ID string warnFolder = "Resources"; // Folder to place the warnFile inside of string warnFile = $"{guildId}warn.json"; // Warning file : guildId + warn.json var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile if (!Directory.Exists(warnFolder)) { Directory.CreateDirectory(warnFolder); } // warnFile does not exist, create it and add in the userId and 1 warning to the user. // If warnFile does exist, load the user's warnings and and 1 warning to the existing warning. if (!File.Exists(warnFolder + "/" + warnFile)) { conf.UserId = user.Id; conf.NumberOfWarnings = 0; conf.WarningMessage = ""; conf.UserUsername = user.Username; conf.ModUsername = Context.User.Username; string json = JsonConvert.SerializeObject(conf, Formatting.Indented); File.WriteAllText(warnFolder + "/" + warnFile, json); } else { ulong currentGuild = Context.Guild.Id; string json = File.ReadAllText(warnFolder + "/" + warnFile); conf = JsonConvert.DeserializeObject <WarnConfig>(json); conf.UserId = user.Id; if (conf.NumberOfWarnings <= 0) { conf.NumberOfWarnings = 0; } else { conf.NumberOfWarnings--; } conf.WarningMessage = ""; conf.UserUsername = user.Username; conf.ModUsername = Context.User.Username; string json1 = JsonConvert.SerializeObject(conf, Formatting.Indented); File.WriteAllText(warnFolder + "/" + warnFile, json1); } await Context.Channel.SendMessageAsync($":white_check_mark: {user.Username}#{user.Discriminator} warning has been cleared. He now has {conf.NumberOfWarnings} warning(s)."); }
public async Task SetChannel(ulong id) { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile guildProfile.LeaveChannel = id; GuildProfiles.SaveProfiles(); await Context.Channel.SendMessageAsync($":white_check_mark: Leave channel has been set to `{id}`"); }
public async Task SetText([Remainder] string message) { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile guildProfile.LeaveMessage = message; GuildProfiles.SaveProfiles(); await Context.Channel.SendMessageAsync($":white_check_mark: Leave message has been set to `{message}`"); }
public async Task AnnounceUserJoined(IGuildUser user) { var guildProfile = GuildProfiles.GetAccount((SocketGuild)user.Guild); // Guild Profile if (guildProfile.GreetModule) { ulong channelId = (guildProfile.GreetChannel); var channel = _client.GetChannel(channelId) as SocketTextChannel; /* Set the channel ID to the database's channel ID */ var gMsg = guildProfile.GreetMessage; string greetMes = gMsg.Replace("@user", user.Mention); await channel.SendMessageAsync($"{greetMes}"); //Welcomes the new user } }
public async Task AnnounceUserLeave(IGuildUser user) { var guildProfile = GuildProfiles.GetAccount((SocketGuild)user.Guild); // Guild Profile if (guildProfile.LeaveModule) { ulong channelId = (guildProfile.LeaveChannel); var channel = _client.GetChannel(channelId) as SocketTextChannel; /* Set the channel ID to the database's channel ID */ var lMsg = guildProfile.LeaveMessage; string leaveMes = lMsg.Replace("@user", user.Username); await channel.SendMessageAsync($"{leaveMes}"); //Welcomes the new user } }
public async Task SetPrefix(string prefix) { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile guildProfile.CmdPrefix = prefix; GuildProfiles.SaveProfiles(); await Context.Channel.SendMessageAsync($"Command prefix has been set to `{prefix}`"); }
public async Task BuyMarriageSlot() { var userPf = UserProfiles.GetAccount(Context.User); // You var gp = GuildProfiles.GetAccount(Context.Guild); string prefix = gp.CmdPrefix; var slots = userPf.MarriageSlots; int currency = 0; switch (slots) { case 5: currency = 2500; userPf.IsBuyingSlot = true; break; case 6: currency = 4500; userPf.IsBuyingSlot = true; break; case 7: currency = 6500; userPf.IsBuyingSlot = true; break; case 8: currency = 8500; userPf.IsBuyingSlot = true; break; case 9: currency = 10000; userPf.IsBuyingSlot = true; break; case 10: await ReplyAsync($"You can't buy anymore slots."); userPf.IsBuyingSlot = false; break; } if (userPf.IsBuyingSlot) { await ReplyAsync($"You can buy a marriage slot for {currency} Nico Nii's. Would you like to buy it?\n\n Type {prefix}buy slot yes or {prefix}buy slot no"); } UserProfiles.SaveProfiles(); }
public async Task AfkUser([Remainder] string message = "") { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile if (guildProfile.AfkModule) { var userProfile = UserProfiles.GetAccount(Context.User); userProfile.Afk = true; userProfile.AfkMessage = message; UserProfiles.SaveProfiles(); await Context.Channel.SendMessageAsync($"Marking you as away **{Context.User.Username}**"); } }
public async Task LeaveDisable() { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile if (guildProfile.LeaveModule) { guildProfile.LeaveModule = false; await Context.Channel.SendMessageAsync(":white_check_mark: Leave Module has been disabled."); } else { await Context.Channel.SendMessageAsync(":white_check_mark: Leave Module has already been disabled."); } GuildProfiles.SaveProfiles(); }
public async Task LevelEnable() { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile if (!guildProfile.LevelModule) { guildProfile.LevelModule = true; await Context.Channel.SendMessageAsync(":white_check_mark: Level Module has been enabled. Members will still get experince, but the message will not appear."); } else { await Context.Channel.SendMessageAsync(":white_check_mark: Level Module has already been enabled."); } GuildProfiles.SaveProfiles(); }
public async Task MarryUser(SocketUser user) { var gp = GuildProfiles.GetAccount(Context.Guild); string prefix = gp.CmdPrefix; if (user != Context.User) { if (UserProfiles.IsMarried(Context.User, user) == false) { if (UserProfiles.HasMarriageSlots(Context.User)) { UserProfiles.AddMarriageProposal(Context.User, user); var embed = new EmbedBuilder() .WithColor(255, 73, 167) .AddField($"{Context.User.Username} has proposed to {user.Username}", $"A marriage is a voluntary and full commitment. It is made in the deepest sense to the exclusion of all others. Before you declare your vows to one another, I want to hear you confirm that it is your intention to be married today. **{user.Username}**, do you come here freely to give yourself to **{Context.User.Username}** in marriage?", false) .AddField(":white_check_mark: To accpet", $"{prefix}acceptmarriage @user", true) .AddField(":negative_squared_cross_mark: To decline", $"{prefix}declinemarriage @user", true) .WithFooter(footer => { footer .WithText($"Take your time though! This proposal won't disappear"); }); await Context.Channel.SendMessageAsync("", embed : embed.Build()); } else { await ReplyAsync($"{Context.User.Mention}, don't have enough marriage slots available."); } } else { await ReplyAsync($"{Context.User.Mention}, you are already married to this user."); } } else { await ReplyAsync($"{Context.User.Mention}, you can't marry yourself."); } }
public async Task WarnBanEnable() { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile if (!guildProfile.WarningsBan) { guildProfile.WarningsBan = true; guildProfile.WarningsKick = false; guildProfile.WarningsMute = false; await Context.Channel.SendMessageAsync(":white_check_mark: Warn Ban Module has been enabled."); } else { await Context.Channel.SendMessageAsync(":white_check_mark: Warn Ban Module has already been enabled."); } GuildProfiles.SaveProfiles(); }
public async Task WarnAmount(uint amount) { SocketGuild target = null; target = Context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile uint previousAmount = guildProfile.NumberofWarnings; if (amount <= 0) { await Context.Channel.SendMessageAsync($":negative_squared_cross_mark: Warn amount cannot be set to {amount}. It must be higher than `0` Setting it back to {previousAmount}"); } else { guildProfile.NumberofWarnings = amount; GuildProfiles.SaveProfiles(); await Context.Channel.SendMessageAsync($":white_check_mark: Warn amount has been set to {amount}"); } }
public async Task KickUser(IGuildUser user, [Remainder] string reason = "No reason provided.") { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile if (guildProfile.KickModule) { string avatarUrl = user.GetAvatarUrl(); string dateTime = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); // Display embed var embed = new EmbedBuilder(); embed.WithTitle("KICK"); embed.WithColor(255, 73, 167); embed.WithDescription($"**{user.Username}#{user.Discriminator}** has been kicked from **{Context.Guild.Name}** with the reason:\n\n **{reason}**"); embed.WithThumbnailUrl(avatarUrl); embed.WithFooter(footer => { footer .WithText($"Kicked by {Context.User.Username}#{Context.User.Discriminator} on {DateTime.Now.ToLongDateString()} at {DateTime.Now.ToShortTimeString()}") .WithIconUrl(Context.Client.GetUser(Context.User.Id).GetAvatarUrl()); }); await Context.Channel.SendMessageAsync("", embed : embed.Build()); // Send Direct Message to user stating he/she has been kicked var dmChannel = await user.GetOrCreateDMChannelAsync(); await dmChannel.SendMessageAsync($"You have been kicked from **{Context.Guild.Name}** with the reason:\n\n **{reason}**"); // Kick the user await user.KickAsync(reason); } else { await Context.Channel.SendMessageAsync("Kick Module has not been enabled yet."); } }
// Happens when the bot receives a message private async Task HandleCommandAsync(SocketMessage s) { var msg = s as SocketUserMessage; // Covnert s to a user message if (msg == null) { return; } var context = new SocketCommandContext(_client, msg); if (context.User.IsBot) { return; } // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = context.Guild; var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile int argPos = 0; // Gets rid of the prefix at which position the prefix ends and the msg begins if (!File.Exists("Resources/guildProfiles.json")) { if (msg.HasStringPrefix(Config.bot.cmdPrefix, ref argPos) || msg.HasMentionPrefix(_client.CurrentUser, ref argPos)) { var result = await _service.ExecuteAsync(context, argPos); // Executes the commands // Check the result if (!result.IsSuccess && result.Error != CommandError.UnknownCommand) { Console.WriteLine(result.ErrorReason); } } } else { if (msg.HasStringPrefix(guildProfile.CmdPrefix, ref argPos) || msg.HasMentionPrefix(_client.CurrentUser, ref argPos)) { var result = await _service.ExecuteAsync(context, argPos); // Executes the commands // Check the result if (!result.IsSuccess && result.Error != CommandError.UnknownCommand) { Console.WriteLine(result.ErrorReason); } } } if (context.Guild.CurrentUser.GetPermissions(context.Guild.GetChannel(context.Channel.Id)).SendMessages == true) { //Console.WriteLine(context.Guild.CurrentUser.Username); // Mute check var userProfile = UserProfiles.GetAccount(context.User); if (userProfile.IsMuted) { await context.Message.DeleteAsync(); return; } // Leveling up Leveling.UserSentMessage((SocketGuildUser)context.User, (SocketTextChannel)context.Channel); // RPS Game #region RPS if (userProfile.IsRPS) { Random rnd = new Random(); int randomInt = rnd.Next(1, 4); string userAns = msg.Content.ToLower(); switch (randomInt) { case 1: // CPU chose rock if (userAns.Contains($"rock")) { await msg.Channel.SendMessageAsync("You chose rock. I chose rock.\nHey! We came to a draw!\n\n**╮( ˘ 、 ˘ )╭**"); if (userProfile.IsRPSGamble) { userProfile.Points += userProfile.GambleAmount / 2; await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount / 2} Nico Nii's"); } userProfile.IsRPS = false; userProfile.IsRPSGamble = false; userProfile.GambleAmount = 0; UserProfiles.SaveProfiles(); } else if (userAns.Contains($"paper")) { await msg.Channel.SendMessageAsync("You chose paper. I chose rock.\nAww, you won!\n\n**。゚・ (>﹏<) ・゚。**"); if (userProfile.IsRPSGamble) { userProfile.Points += userProfile.GambleAmount * 2; await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount * 2} Nico Nii's"); } userProfile.IsRPS = false; userProfile.IsRPSGamble = false; userProfile.GambleAmount = 0; UserProfiles.SaveProfiles(); } else if (userAns.Contains($"scissors")) { await msg.Channel.SendMessageAsync("You chose scissors. I chose rock.\nYay! I won!\n\n**(๑˃ᴗ˂)ﻭ**"); userProfile.IsRPS = false; userProfile.IsRPSGamble = false; userProfile.GambleAmount = 0; UserProfiles.SaveProfiles(); } break; case 2: // CPU chose paper if (userAns.Contains($"paper")) { await msg.Channel.SendMessageAsync("You chose paper. I chose paper.\nHey! We came to a draw!\n\n**╮( ˘ 、 ˘ )╭**"); if (userProfile.IsRPSGamble) { userProfile.Points += userProfile.GambleAmount / 2; await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount / 2} Nico Nii's"); } userProfile.IsRPS = false; userProfile.IsRPSGamble = false; userProfile.GambleAmount = 0; UserProfiles.SaveProfiles(); } else if (userAns.Contains($"rock")) { await msg.Channel.SendMessageAsync("You chose rock. I chose paper.\nYay! I won!\n\n**(๑˃ᴗ˂)ﻭ**"); userProfile.IsRPS = false; userProfile.IsRPSGamble = false; userProfile.GambleAmount = 0; UserProfiles.SaveProfiles(); } else if (userAns.Contains($"scissors")) { await msg.Channel.SendMessageAsync("You chose scissors. I chose paper.\nAww, you won!\n\n**。゚・ (>﹏<) ・゚。**"); if (userProfile.IsRPSGamble) { userProfile.Points += userProfile.GambleAmount * 2; await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount * 2} Nico Nii's"); } userProfile.IsRPS = false; userProfile.IsRPSGamble = false; userProfile.GambleAmount = 0; UserProfiles.SaveProfiles(); } break; case 3: // CPU chose scissors if (userAns.Contains($"scissors")) { await msg.Channel.SendMessageAsync("You chose scissors. I chose scissors.\nHey! We came to a draw!\n\n**╮( ˘ 、 ˘ )╭**"); if (userProfile.IsRPSGamble) { userProfile.Points += userProfile.GambleAmount / 2; await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount / 2} Nico Nii's"); } userProfile.IsRPS = false; userProfile.IsRPSGamble = false; userProfile.GambleAmount = 0; UserProfiles.SaveProfiles(); } else if (userAns.Contains($"rock")) { await msg.Channel.SendMessageAsync("You chose rock. I chose scissors.\nAww, you won!\n\n**。゚・ (>﹏<) ・゚。**"); if (userProfile.IsRPSGamble) { userProfile.Points += userProfile.GambleAmount * 2; await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount * 2} Nico Nii's"); } userProfile.IsRPS = false; userProfile.IsRPSGamble = false; userProfile.GambleAmount = 0; UserProfiles.SaveProfiles(); } else if (userAns.Contains($"paper")) { await msg.Channel.SendMessageAsync("You chose paper. I chose scissors.\nYay! I won!\n\n**(๑˃ᴗ˂)ﻭ**"); userProfile.IsRPS = false; userProfile.IsRPSGamble = false; userProfile.GambleAmount = 0; UserProfiles.SaveProfiles(); } break; default: break; } } #endregion if (context.Guild.CurrentUser.GetPermissions(context.Guild.GetChannel(context.Channel.Id)).EmbedLinks == true) { // AFK #region AFK if (guildProfile.AfkModule) { // Set the user back from being AFK if they are AFK if (!s.Author.IsBot && !s.Content.Contains($"{guildProfile.CmdPrefix}afk")) { var afkUser = UserProfiles.GetAccount(s.Author); if (s.Author.Id == afkUser.ID) { if (afkUser.Afk) { afkUser.Afk = false; afkUser.AfkMessage = ""; UserProfiles.SaveProfiles(); var embed = new EmbedBuilder(); embed.Color = new Color(222, 77, 156); embed.Title = $"You are now set as back **{s.Author.Username}**!"; await s.Channel.SendMessageAsync("", embed : embed.Build()); } } } // If the user pings an AFK person, give them a notice var userMentioned = s.MentionedUsers.FirstOrDefault(); if (userMentioned != null) { var afkUser = UserProfiles.GetAccount(userMentioned); // Get the mentioned user string avatarUrl = userMentioned.GetAvatarUrl(); if (afkUser.Afk) { var embed = new EmbedBuilder(); embed.Color = new Color(222, 77, 156); embed.Title = $"AFK"; embed.WithDescription($"**{userMentioned.Username}** is currently away. They left this message:\n\n **{afkUser.AfkMessage}**"); embed.WithThumbnailUrl(avatarUrl); await s.Channel.SendMessageAsync("", embed : embed.Build()); } } } #endregion } } }
public async Task WarnUser(IGuildUser user, [Remainder] string reason = "No Reason") { // Create a target of type SocketGuild so we can retreive information from the GuildProfiles SocketGuild target = null; target = Context.Guild; string guildId = Context.Guild.Id.ToString(); // Guild ID string warnFolder = "Resources"; // Folder to place the warnFile inside of string warnFile = $"{guildId}warn.json"; // Warning file : guildId + warn.json var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile if (!Directory.Exists(warnFolder)) { Directory.CreateDirectory(warnFolder); } // warnFile does not exist, create it and add in the userId and 1 warning to the user. // If warnFile does exist, load the user's warnings and and 1 warning to the existing warning. if (!File.Exists(warnFolder + "/" + warnFile)) { conf.UserId = user.Id; conf.NumberOfWarnings = 1; conf.WarningMessage = reason; conf.UserUsername = user.Username; conf.ModUsername = Context.User.Username; string json = JsonConvert.SerializeObject(conf, Formatting.Indented); File.WriteAllText(warnFolder + "/" + warnFile, json); } else { ulong currentGuild = Context.Guild.Id; string json = File.ReadAllText(warnFolder + "/" + warnFile); conf = JsonConvert.DeserializeObject <WarnConfig>(json); conf.UserId = user.Id; conf.NumberOfWarnings++; conf.WarningMessage = reason; conf.UserUsername = user.Username; conf.ModUsername = Context.User.Username; string json1 = JsonConvert.SerializeObject(conf, Formatting.Indented); File.WriteAllText(warnFolder + "/" + warnFile, json1); } var dmChannel = await user.GetOrCreateDMChannelAsync(); await dmChannel.SendMessageAsync($"You have been warned in **{Context.Guild.Name}** with the reason:\n\n **{reason}**\n\n This makes {conf.NumberOfWarnings} warning(s)."); await Context.Channel.SendMessageAsync($":white_check_mark: {user.Username}#{user.Discriminator} has been warned."); // Check warnings if (conf.NumberOfWarnings == guildProfile.NumberofWarnings) { if (guildProfile.WarningsBan) { await dmChannel.SendMessageAsync($"You have been banned from **{Context.Guild.Name}** with the reason:\n\n Warned **{conf.NumberOfWarnings}** time(s)"); await user.Guild.AddBanAsync(user, 7, $"Banned for having {guildProfile.NumberofWarnings} warning(s)"); conf.NumberOfWarnings = 0; } else if (guildProfile.WarningsKick) { await dmChannel.SendMessageAsync($"You have been kicked from **{Context.Guild.Name}** with the reason:\n\n Warned **{conf.NumberOfWarnings}** time(s)"); await user.KickAsync("reason"); conf.NumberOfWarnings = 0; } else if (guildProfile.WarningsMute) { // Mute } else { } } string json2 = JsonConvert.SerializeObject(conf, Formatting.Indented); File.WriteAllText(warnFolder + "/" + warnFile, json2); }