public async Task ServerStats() { int memberCount = Context.Guild.MemberCount; DateTimeOffset date = Context.Guild.CreatedAt; string name = Context.Guild.Name; string owner = Context.Guild.Owner.Username; ServerConfig serverConfig = ServerConfigs.GetConfig(Context.Guild); bool reqV = serverConfig.RequiresVerification; string verification = string.Format("\nRequires Verification: **{0}**", reqV); if (reqV) { SocketRole vRole = Context.Guild.GetRole(serverConfig.VerificationRoleID); verification += string.Format("\nVerified Role: **{0}**", vRole.Name); } string configs = "\nBot Prefix: **" + serverConfig.Prefix + "**" + verification + "\nAFK Channel: **" + Context.Guild.GetVoiceChannel(serverConfig.AFKChannelID).Name + "**\nAFK Timeout: **" + serverConfig.AFKTimeout + "**\nAntispam Mute Time: **" + serverConfig.AntiSpamTime + "**\nAntispam Warn Ban: **" + serverConfig.AntiSpamWarn; string msg = "Server Name: **" + name + "**\nOwner: **" + owner + "**\nMember Count: **" + memberCount + "**\nDate Created: **" + date.ToString("MM/dd/yyyy hh:mm:ss") + "**" + configs + "**\n\n__Roles__\n**" + getAllRoles((SocketGuildUser)Context.User) + "**"; var result = from s in Context.Guild.VoiceChannels where s.Name.Contains("Member Count") select s; await PrintEmbedMessage("Server Stats", msg, iconUrl : Context.Guild.IconUrl); SocketVoiceChannel memberChan = result.FirstOrDefault(); await memberChan.ModifyAsync(m => { m.Name = "Member Count: " + Context.Guild.MemberCount; }); DataStorage.AddPairToStorage(memberChan.Guild.Name + " MemberChannel", memberChan.Id.ToString()); }
public static void GetAllTextChannels(IEnumerable <SocketTextChannel> channels) { foreach (var channel in channels) { string channelName = channel.Name; DataStorage.AddPairToStorage(channel.Guild.Name + " | " + channelName, channel.Id.ToString()); } }
public async Task GetData() { if (Context.User.Id != 253313886466473997) { return; } await Context.Channel.SendMessageAsync($"Data has {DataStorage.GetPairsCount()} pairs"); DataStorage.AddPairToStorage("Count" + DataStorage.GetPairsCount(), "theCount" + DataStorage.GetPairsCount()); }
public static void GetAllVoiceChannels(IEnumerable <SocketVoiceChannel> channels) { foreach (var channel in channels) { string channelName = channel.Name; if (!channelName.Contains("Member Count") && !channelName.Contains("User Count") && !channelName.Contains("Bot Count")) { DataStorage.AddPairToStorage(channel.Guild.Name + " | " + channelName, channel.Id.ToString()); } } }
public static SocketTextChannel GetTChannel(IEnumerable <SocketTextChannel> channels, string channelName) { foreach (var channel in channels) { if (channel.Name.ToLower().Contains(channelName.ToLower())) { DataStorage.AddPairToStorage(channel.Guild.Name + " | " + channel.Name, channel.Id.ToString()); return(channel); } } return(null); }
public async Task Echo([Remainder] string message) { var embed = new EmbedBuilder(); //embed.WithTitle(Context.User.Username +" says"); embed.WithDescription(message); embed.WithColor(new Color(0, 255, 0)); await Context.Channel.SendMessageAsync("", embed : embed); DataStorage.AddPairToStorage(Context.User + DateTime.Now.ToLongTimeString(), ""); }
public async Task Echo([Remainder] string message) { //var embed = new EmbedBuilder(); //embed.WithTitle(Context.User.Username +" says"); //embed.WithDescription(message); //embed.WithColor(new Color(0, 255, 0)); var dmchannel = await Context.User.GetOrCreateDMChannelAsync(); await dmchannel.SendMessageAsync(message); DataStorage.AddPairToStorage(Context.User.Mention + DateTime.Now.ToLongTimeString(), ""); }
public static async Task updMemberChan(SocketGuild guild) { int botcount = 0; IReadOnlyCollection <SocketGuildUser> users = guild.Users; foreach (SocketGuildUser u in users) { if (u.IsBot) { botcount++; } } bool updateChan = false; foreach (SocketVoiceChannel chan in guild.VoiceChannels) { if (chan.Name.Contains("Member Count")) { if (!updateChan) { int members = int.Parse(chan.Name.Split(':')[1]); if (members != chan.Guild.Users.Count) { updateChan = true; break; } } } } foreach (SocketVoiceChannel chan in guild.VoiceChannels) { if (chan.Name.Contains("Member Count") && updateChan) { await chan.ModifyAsync(m => { m.Name = "Member Count: " + chan.Guild.MemberCount; }); DataStorage.AddPairToStorage(chan.Guild.Name + " MemberChannel", chan.Id.ToString()); } if (chan.Name.Contains("User Count") && updateChan) { await chan.ModifyAsync(m => { m.Name = "User Count: " + (chan.Guild.MemberCount - botcount); }); DataStorage.AddPairToStorage(chan.Guild.Name + " UserChannel", chan.Id.ToString()); } if (chan.Name.Contains("Bot Count") && updateChan) { await chan.ModifyAsync(m => { m.Name = "Bot Count: " + botcount; }); DataStorage.AddPairToStorage(chan.Guild.Name + " BotChannel", chan.Id.ToString()); } } }
//[RequireUserPermission(GuildPermission.Administrator)] public async Task getlin([Remainder] string arg = "") { if (!Selectedrole((SocketGuildUser)Context.User)) { await Context.Channel.SendMessageAsync(":x: You don't have Permisson do to that" + Context.User.Username + " >(O w O;)<"); return; } var dmchannel = await Context.User.GetOrCreateDMChannelAsync(); await dmchannel.SendMessageAsync(Utilities.GetAlert("")); DataStorage.AddPairToStorage(Context.User + DateTime.Now.ToLongTimeString(), ""); }
public async Task PickOne([Remainder] string message) { string[] options = message.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Random r = new Random(); string selection = options[r.Next(0, options.Length)]; var embed = new EmbedBuilder(); embed.WithTitle("Choice for " + Context.User.Username); embed.WithDescription(selection); embed.WithColor(new Color(255, 255, 0)); embed.WithThumbnailUrl(Context.User.GetAvatarUrl()); await Context.Channel.SendMessageAsync("", false, embed.Build()); DataStorage.AddPairToStorage(Context.User.Username + DateTime.Now.ToLongTimeString(), selection); }
public static SocketVoiceChannel GetVChannel(IEnumerable <SocketVoiceChannel> channels, string channelName) { foreach (var channel in channels) { if (channel.Name.ToLower().Contains(channelName.ToLower())) { if (!channelName.Contains("Member Count") && !channelName.Contains("User Count") && !channelName.Contains("Bot Count")) { DataStorage.AddPairToStorage(channel.Guild.Name + " | " + channel.Name, channel.Id.ToString()); } return(channel); } } return(null); }
private async void RegisterUserLocation(string message) { string userLocation = message.Substring(message.IndexOf("set") + "set".Length).Trim(); // get all the user the first occurance of the word "set" // check to see if user has existing location registered if (DataStorage.HasKey(Context.User.Username) && !String.IsNullOrWhiteSpace(message)) { DataStorage.ReplaceKeyValue(Context.User.Username, userLocation); await Context.Channel.SendMessageAsync("updated location to " + userLocation); } // otherwise, register a new location for the user else { DataStorage.AddPairToStorage(Context.User.Username, userLocation); await Context.Channel.SendMessageAsync(Context.User.Username + " successfully added " + userLocation + " as their default location."); } }
public async Task Pickone([Remainder] string message) { string[] options = message.Split(new string[] { "или" }, StringSplitOptions.RemoveEmptyEntries); Random r = new Random(); string selection = options[r.Next(0, options.Length)]; var embed = new EmbedBuilder(); embed.WithTitle("трунь"); embed.WithDescription(selection); embed.WithColor(new Color(255, 255, 0)); embed.WithThumbnailUrl("https://cdn.discordapp.com/emojis/403898766727577611.png?v=1"); await Context.Channel.SendMessageAsync("", false, embed); DataStorage.AddPairToStorage(Context.User.Username + " " + DateTime.Today + DateTime.Now.ToLongTimeString(), selection); }
public async Task PickOne([Remainder] string message) { string[] options = message.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Random r = new Random(); string selection = options[r.Next(0, options.Length)]; var embed = new EmbedBuilder(); embed.WithTitle("Choice for " + Context.User.Username); embed.WithDescription(selection); embed.WithColor(new Color(255, 255, 0)); embed.WithThumbnailUrl("https://orig00.deviantart.net/3033/f/2016/103/0/c/mercy_by_raichiyo33-d9yufl4.jpg"); await Context.Channel.SendMessageAsync("", false, embed); DataStorage.AddPairToStorage(Context.User.Username + DateTime.Now.ToLongDateString(), selection); }
public async Task choose([Remainder] string message) { string[] options = message.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Random r = new Random(); string selection = options[r.Next(0, options.Length)]; var embed = new EmbedBuilder(); embed.WithTitle("Choice for " + Context.User.Username); embed.WithDescription(selection); embed.WithColor(new Color(0, 255, 0)); embed.WithThumbnailUrl("https://s-media-cache-ak0.pinimg.com/originals/b2/23/18/b22318a9a6850a5c4de6cf530f499bef.jpg"); await Context.Channel.SendMessageAsync("", false, embed); DataStorage.AddPairToStorage(Context.User.Username + DateTime.Now.ToShortTimeString(), selection); }
public async Task SelectOne([Remainder] string message) { string[] options = message.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Random r = new Random(); string selection = options[r.Next(0, options.Length)]; var embed = new EmbedBuilder(); embed.WithTitle("THE CHOICE HAS BEEN MADE: " + Context.User.Username); embed.WithDescription(selection); embed.WithColor(new Color(254, 127, 156)); embed.WithThumbnailUrl("http://i0.kym-cdn.com/photos/images/original/000/926/994/729.gif"); Context.User.GetAvatarUrl(); await Context.Channel.SendMessageAsync("", false, embed); DataStorage.AddPairToStorage(Context.User.Username + DateTime.Now.ToLongTimeString(), selection); }
public async Task status([Remainder] string arg = "") { SocketUser target = null; var mentionUser = Context.Message.MentionedUsers.FirstOrDefault(); target = mentionUser ?? Context.User; var account = UAccounts.GetAccount(target); var embed = new EmbedBuilder(); embed.WithColor(new Color(51, 221, 255)); embed.WithThumbnailUrl(Context.User.GetAvatarUrl()); embed.AddInlineField("Name", Context.User.Username); embed.AddInlineField("Current Corelvl", account.lvlnumber); embed.AddInlineField("Current EXP", account.EXP); embed.AddInlineField("Stardust", account.points); //embed.WithTitle($":book: {target.Username}'s Current Status : \n {account.EXP} EXP \n {account.points} StarDust"); await Context.Channel.SendMessageAsync("", false, embed); DataStorage.AddPairToStorage(Context.User + DateTime.Now.ToLongTimeString(), ""); }
private async Task Client_MessageReceived(SocketMessage s) { var msg = s as SocketUserMessage; if (msg == null) { return; } var context = new SocketCommandContext(client, msg); ulong guildID = 0; SocketTextChannel generalchan = null; ServerConfig config = new ServerConfig(); UserAccount userAccount = null; Antispam.SpamAccount spamAccount = null; //Load Accounts UserAccounts.LoadUserAccts(); SteamAccounts.LoadUserAccts(); ServerConfigs.LoadServerConfigs(); NanoPool.LoadAccounts(); MemeLoader.LoadMemes(); Antispam.LoadSpamAccount(); GiveawayManager.LoadGiveaways(); //----------Do Tests-------- //if (!context.IsPrivate) await RepeatingTimer.UpdateAuditLog(context.Guild);] //Mute Check userAccount = UserAccounts.GetAccount(context.User); spamAccount = Antispam.GetAccount(context.User); if (oldMessage.Count > 0) { if (oldMessage[oldMessage.Count - 1].Content == s.Content) { for (int i = 0; i < oldMessage.Count; i++) { if (oldMessage[i].Content == s.Content && oldMessage[i].Embeds.Count == 0) { msgCount++; if (msgCount >= 5) { try { await s.DeleteAsync(); } catch (Exception ex) { string exMsg = DateTime.Now + " | EXCEPTION: " + ex.Message; Console.WriteLine(exMsg); Log.LogException(exMsg); } string mes = DateTime.Now + " | " + context.User + " suspected raid account. Ban request...."; Console.WriteLine(mes); } } } } } if (oldMessage.Count >= 20) { oldMessage.RemoveAt(0); } oldMessage.Add(s); if (!context.IsPrivate) { config = ServerConfigs.GetConfig(context.Guild); RepeatingTimer.channel = (SocketTextChannel)context.Channel; if (!updated.Contains(context.Guild)) { ServerConfigs.UpdateServerConfig(context.Guild, config); updated.Add(context.Guild); } if (config.RequiresVerification) { if (GetTChannel(context.Guild.TextChannels, "verification") == null) { await context.Guild.CreateTextChannelAsync("verification"); } } if (userAccount.IsMuted) { await context.Message.DeleteAsync(); return; } //Get Guild ID guildID = context.Guild.Id; DataStorage.AddPairToStorage(context.Guild.Name + "ID", guildID.ToString()); generalchan = GetTChannel(context.Guild.TextChannels, "general"); } //Bot Check if (!context.User.IsBot) { if (!context.IsPrivate) { if (!config.AllowAdvertising) { if (context.Message.Content.Contains(context.Guild.EveryoneRole.ToString()) && context.Message.Content.Contains("https://discord.gg/")) { await context.Message.DeleteAsync(); await context.Channel.SendMessageAsync(context.User.Mention + " Advertising discord servers is not allowed here."); return; } } if (config.BlockMentionEveryone) { if (context.Message.Content.Contains(context.Guild.EveryoneRole.ToString())) { await context.Message.DeleteAsync(); await context.Channel.SendMessageAsync(context.User.Mention + " mentioning everyone is prohibited!"); return; } } //Check for raid from multiple account spam //Add when you wake up... spamAccount.LastMessages.Add(DateTime.Now); if (spamAccount.BanAmount > 0) { if (Math.Abs(spamAccount.LastBan.Subtract(DateTime.Now).Days) > 10) //Reset ban amount after 10 days { spamAccount.BanAmount = 0; } } if (spamAccount.LastMessages.Count > 3) { //Get last 4 messages sent DateTime d1 = spamAccount.LastMessages[0]; DateTime d2 = spamAccount.LastMessages[1]; DateTime d3 = spamAccount.LastMessages[2]; DateTime d4 = spamAccount.LastMessages[3]; TimeSpan t1 = new TimeSpan(); TimeSpan t2 = new TimeSpan(); TimeSpan t3 = new TimeSpan(); //Subtract them from each other by Milliseconds t1 = d1.Subtract(d2); t2 = d2.Subtract(d3); t3 = d3.Subtract(d4); double mil1 = Math.Abs(t1.TotalMilliseconds); double mil2 = Math.Abs(t2.TotalMilliseconds); double mil3 = Math.Abs(t3.TotalMilliseconds); //Console.WriteLine(mil1 + "\n" + mil2 + "\n" + mil3); //If all past 4 messages are within spam threshold then its considerd spam if (mil1 <= Antispam.millisecondThreshold && //Threshold is 5 seconds mil2 <= Antispam.millisecondThreshold && mil3 <= Antispam.millisecondThreshold) { spamAccount.BanAmount++; string message = ""; DateTime banTime = DateTime.Now; if (spamAccount.BanAmount < config.AntiSpamWarn) { message = "\nPlease stop spamming you have been muted for 30 seconds!"; banTime = DateTime.Now.AddSeconds(30); } if (spamAccount.BanAmount >= config.AntiSpamWarn && spamAccount.BanAmount < config.AntiSpamThreshold) { int time = (int)config.AntiSpamTime; message = "\nYou have been muted for " + time + " Minutes! " + context.Guild.Owner.Mention; banTime = DateTime.Now.AddMinutes(time); } if (spamAccount.BanAmount > config.AntiSpamThreshold) { SocketGuildUser user = (SocketGuildUser)context.User; await user.BanAsync(1, "Spamming"); await context.Channel.SendMessageAsync(context.User.Username + " was banned for 1 day for spamming!"); return; } spamAccount.BanTime = banTime; spamAccount.LastBan = DateTime.Now; await context.Channel.SendMessageAsync(context.User.Mention + message); spamAccount.LastMessages.Clear(); Antispam.UpdateAccount(context.User, spamAccount); Antispam.SaveAccounts(); userAccount.IsMuted = true; UserAccounts.SaveAccounts(); return; } spamAccount.LastMessages.Clear(); } Antispam.SaveAccounts(); if (config.EnableServerStats) { //If stat channels dont exist await CreateStatChannels(context.Guild); await updMemberChan(context.Guild); //Update Stat channels } if (config.EnableLevelSystem) { uint oldlvl = userAccount.LevelNumber; userAccount.XP += 10; //Xp gain userAccount.Points += 10; //Pointshop if (oldlvl != userAccount.LevelNumber) { for (int i = 0; i < LevelingSytem.levelUp.Length; i++) { if (userAccount.LevelNumber == LevelingSytem.levelUp[i]) { IGuildUser user = (IGuildUser)context.User; IRole[] r = user.Guild.Roles.ToArray(); IRole addrole = null; for (int i2 = 0; i2 < r.Length; i2++) { if (r[i2].Name.ToLower() == LevelingSytem.upgradeRoles[i].ToLower()) { addrole = r[i2]; break; } } if (addrole != null) { ulong?roleID = null; foreach (ulong r2 in user.RoleIds) { if (r2 == addrole.Id) { roleID = r2; break; } }//end foreach loop if (roleID == null) { await user.AddRoleAsync(addrole); await context.Channel.SendMessageAsync("__" + user.Username + "__ earned role **" + addrole + "**!", false); } //end if roleID } //end if addrole != null } // end if level up } //end levels loop string message = "Congrats " + context.User.Mention + ", You just advanced to **Level " + userAccount.LevelNumber + "!**"; await context.Channel.SendMessageAsync(message); } //end level check } //end level system check } //end if EnableLevelSystem UserAccounts.SaveAccounts(); } //end isPrivate check int argPos = 0; if (msg.HasStringPrefix("" + config.Prefix, ref argPos) || msg.HasMentionPrefix(client.CurrentUser, ref argPos)) { if (context.IsPrivate) { config = new ServerConfig(); } else { config = ServerConfigs.GetConfig(context.Guild); } IResult result = null; result = await service.ExecuteAsync(context, argPos, null); if (!result.IsSuccess && result.Error != CommandError.UnknownCommand) { bool errorCheck = true; if (context.Message.Content.Contains("creatememe") && context.Message.Attachments.Count > 0) { if (result.ErrorReason.Contains("User not found")) { errorCheck = false; } } if (errorCheck) { string message = "Error when running this command\n**" + result.ErrorReason + "**\n\nView console for more info"; var embed = new EmbedBuilder(); embed.WithTitle("Command Error"); embed.WithDescription(message); embed.WithColor(config.EmbedColorRed, config.EmbedColorGreen, config.EmbedColorBlue); if (config.FooterText != "") { embed.WithFooter(config.FooterText); } if (config.TimeStamp) { embed.WithCurrentTimestamp(); } await context.Channel.SendMessageAsync("", false, embed.Build()); Console.WriteLine(result.ErrorReason); Console.WriteLine(result.Error); } } } GetAllVoiceChannels(context.Guild.VoiceChannels); GetAllTextChannels(context.Guild.TextChannels); }
public async Task GetInfo() { await Context.Channel.SendMessageAsync("Document has " + DataStorage.GetPairsCount() + " items."); DataStorage.AddPairToStorage("Count" + DataStorage.GetPairsCount(), "TheCount" + DataStorage.GetPairsCount()); }
public async Task GetData() { await Context.Channel.SendMessageAsync("Data Has " + DataStorage.GetPairsCount() + " pairs."); DataStorage.AddPairToStorage("Count" + DataStorage.GetPairsCount(), "TheCount" + DataStorage.GetPairsCount()); }
public async Task GetData() { await Context.Channel.SendMessageAsync($"Data has {DataStorage.GetPairsCount()} elements."); DataStorage.AddPairToStorage("Nickname", "LeeGe"); }