private async Task BotClient_GuildAvailable(SocketGuild guild) { try { logger.LogInformation("{guildName} is available.", guild.Name); var serverOptions = discordOptions.Servers.SingleOrDefault(o => o.ServerId == guild.Id); if (serverOptions != null) { var category = guild.GetCategoryChannel(serverOptions.ChannelCategoryId); if (category != null) { var lounge = category.Channels.SingleOrDefault(o => o.Name == serverOptions.LoungeChannelName); if (lounge == null) { logger.LogInformation("Create lounge channel named {lounge}.", serverOptions.LoungeChannelName); var newLounge = await guild.CreateVoiceChannelAsync(serverOptions.LoungeChannelName, props => { props.CategoryId = category.Id; }); logger.LogInformation("Created lounge channel {loungeId}", newLounge.Id); } } } } catch (Exception ex) { logger.LogError(ex, "Cannot prepare server [{guildId}] {guildName}", guild.Id, guild.Name); } }
public async Task <IGuildChannel> CreateVoiceChannelAsync(DiscordServerOptions serverOptions, SocketGuild guild, int?frequency) { var channelName = frequency.HasValue ? CreateChannelNameFromFrequency(serverOptions, frequency) : serverOptions.LoungeChannelName; var channel = guild.Channels.FirstOrDefault(c => c.Name == channelName); if (channel != null) { return(channel); } var voiceChannel = await guild.CreateVoiceChannelAsync(channelName, props => { props.CategoryId = serverOptions.ChannelCategoryId; props.Bitrate = serverOptions.ChannelBitrate; }); // Note: Bot will not try to add permission. // Instead, permission should be set at the category level so that the channel can inherit. logger.LogInformation("Created new channel {channelName}", channelName); return(voiceChannel); }
private async Task CreateChannel(SocketGuild guild) { var newChannel = await guild.CreateVoiceChannelAsync(DEFAULT_DYNAMIC_CHANNEL_NAME); await newChannel.AddPermissionOverwriteAsync(dyno, new Discord.OverwritePermissions()); log.Debug("Created channel: " + newChannel.Id + " - \"" + newChannel.Name + "\""); }
public static async Task CheckFullAndAddIf(SocketGuild server) { List <VoiceChannel> channels = allVoiceChannels.Values.ToList(); int count = channels.Where(x => !x.ignore).Count(); fullChannels = 0; foreach (VoiceChannel cur in channels) { if (cur.ignore) { continue; } if (cur.GetChannel() != null) { SocketVoiceChannel channel = cur.GetChannel(); if (Utility.ForceGetUsers(channel.Id).Count != 0) { fullChannels++; } } } // If the amount of full channels are more than or equal to the amount of channels, add a new one. if (fullChannels == count) { if (nameQueue.Count > 0 && awaitingChannels.Count == 0) { string channelName = GetAvailableExtraName(true); RestVoiceChannel channel; try { Logging.Log(Logging.LogType.BOT, "Creating new voice channel: " + channelName); Task <RestVoiceChannel> createTask = server.CreateVoiceChannelAsync(channelName.Split(';')[0]); channel = await createTask; } catch (Exception e) { throw e; } int channelPos = temporaryChannels.Count + addChannelsIndex; temporaryChannels.Add(channel); allVoiceChannels.Add(channel.Id, new VoiceChannel(channel.Id, channelName, channelPos)); awaitingChannels.Remove(channelName); IEnumerable <VoiceChannel> allChannels = allVoiceChannels.Values.ToList(); foreach (VoiceChannel loc in allChannels) { if (loc.position >= channelPos && loc.GetChannel() as IVoiceChannel != channel) { loc.position++; } } } } }
public static async Task <RestVoiceChannel> CreateAutoVCChannel(SocketGuild guild, string baseName) { RestVoiceChannel vcChannel = await guild.CreateVoiceChannelAsync($"➕ New {baseName} VC"); ServerAudioVoiceChannel audioVoiceChannel = new ServerAudioVoiceChannel(vcChannel.Id, baseName); ServerListsManager.GetServer(guild).AutoVoiceChannels.Add(audioVoiceChannel); ServerListsManager.SaveServerList(); return(vcChannel); }
public async Task CreateStatChannels(SocketGuild guild) { if (GetVChannel(guild.VoiceChannels, "Bot Count") == null) { int botcount = 0; IReadOnlyCollection <SocketGuildUser> users = guild.Users; foreach (SocketGuildUser user in users) { if (user.IsBot) { botcount++; } } RestVoiceChannel x = await guild.CreateVoiceChannelAsync("Bot Count: " + botcount); await x.ModifyAsync(m => { m.Position = 1; m.UserLimit = 0; }); } if (GetVChannel(guild.VoiceChannels, "User Count") == null) { int botcount = 0; IReadOnlyCollection <SocketGuildUser> users = guild.Users; foreach (SocketGuildUser user in users) { if (user.IsBot) { botcount++; } } RestVoiceChannel z = await guild.CreateVoiceChannelAsync("User Count: " + (users.Count - botcount)); await z.ModifyAsync(m => { m.Position = 2; m.UserLimit = 0; }); } if (GetVChannel(guild.VoiceChannels, "Member Count") == null) { IReadOnlyCollection <SocketGuildUser> users = guild.Users; RestVoiceChannel z = await guild.CreateVoiceChannelAsync("Member Count: " + users.Count); await z.ModifyAsync(m => { m.Position = 0; m.UserLimit = 0; }); } }
private async Task UpdatePublicChannels() { await GetPublicChannels(); if (freepublicchannels.Count < 2) { var message = await _guild.CreateVoiceChannelAsync("Public " + (publicchannels.Capacity + 1)); } if (freepublicchannels.Count > 2 & publicchannels.Count > 6) { await _guild.GetChannel(publicchannels.Last().Id).DeleteAsync(); } }
private async Task <RestVoiceChannel> CreateNewChannel(SocketGuild guild, string channelName) { var channel = await guild.CreateVoiceChannelAsync(channelName); _temporaryChannels.Add(channel.Id); ulong catagory = _newChannelCategory.GetValue(); if (catagory != 0) { await channel.ModifyAsync(x => x.CategoryId = catagory); } return(channel); }
public virtual Task <RestVoiceChannel> CreateVoiceChannelAsync(string name, Action <VoiceChannelProperties>?func = null, RequestOptions?options = null) { return(_socketGuild.CreateVoiceChannelAsync(name, func, options)); }
private async Task OnReactionAdded(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel channel, SocketReaction reaction) { IGuildChannel guildChannel = channel as IGuildChannel; SocketGuild guild = guildChannel.Guild as SocketGuild; //GlobalUtils.client.Guilds.FirstOrDefault(); SocketUser user = GlobalUtils.client.GetUser(reaction.UserId); SocketGuildUser guser = guild.GetUser(user.Id); if (user.IsBot) { return; // Task.CompletedTask; } // add vote Console.WriteLine($"Emoji added: {reaction.Emote.Name}"); if (pendingGames.ContainsKey(reaction.MessageId) && reaction.Emote.Name == "\u2705") { pendingGames[reaction.MessageId].votes++; if (pendingGames[reaction.MessageId].votes >= voteThreshold || user.Id == 346219993437831182) { Console.WriteLine("Adding game: " + pendingGames[reaction.MessageId].game); // add the game now! RestRole gRole = await guild.CreateRoleAsync(pendingGames[reaction.MessageId].game); Console.WriteLine("Game Role: " + gRole.Name); RestTextChannel txtChan = await guild.CreateTextChannelAsync(pendingGames[reaction.MessageId].game, x => { x.CategoryId = gamesText.Id; }); Console.WriteLine("Text Channel: " + txtChan.Name); await txtChan.AddPermissionOverwriteAsync(gRole, permissions); RestVoiceChannel voiceChan = await guild.CreateVoiceChannelAsync(pendingGames[reaction.MessageId].game, x => { x.CategoryId = gamesVoice.Id; }); Console.WriteLine("Voice Channel: " + voiceChan.Name); await voiceChan.AddPermissionOverwriteAsync(gRole, permissions); games.Add(new GameInfo(pendingGames[reaction.MessageId].game, txtChan.Id, voiceChan.Id)); // remove poll message, add new game announcement and remove pending game ISocketMessageChannel chan = gameChannel as ISocketMessageChannel; await chan.DeleteMessageAsync(reaction.MessageId); EmbedBuilder embed = new EmbedBuilder(); embed.WithTitle("New Game Added"); embed.WithDescription($"`{pendingGames[reaction.MessageId].game}`\n"); embed.WithColor(GlobalUtils.color); await chan.SendMessageAsync("", false, embed.Build()); pendingGames.Remove(reaction.MessageId); UpdateOrAddRoleMessage(); } } Console.WriteLine($"Emoji added: {reaction.MessageId} == {roleMessageId} : {reaction.MessageId == roleMessageId}"); Console.WriteLine("Add Game Role: " + guser.Nickname); if (reaction.MessageId == roleMessageId) { // they reacted to the correct role message Console.WriteLine("Add Game Role: " + guser.Nickname); for (int i = 0; i < games.Count && i < GlobalUtils.menu_emoji.Count <string>(); i++) { if (GlobalUtils.menu_emoji[i] == reaction.Emote.Name) { Console.WriteLine("Emoji Found"); var result = from a in guild.Roles where a.Name == games[i].game select a; SocketRole role = result.FirstOrDefault(); Console.WriteLine("Role: " + role.Name); await guser.AddRoleAsync(role); } } } Console.WriteLine("what?!"); Save(); }
public async Task ChangeGameAndRole(SocketGuildUser beforeChangeUser, SocketGuildUser afterChangeUser) { SocketGuildUser user = afterChangeUser; IRole gameRole = null; SocketGuild guild = user.Guild; if (!string.IsNullOrWhiteSpace(beforeChangeUser.Activity?.Name) || !string.IsNullOrWhiteSpace(afterChangeUser.Activity?.Name)) { if (beforeChangeUser.Activity?.Name != afterChangeUser.Activity?.Name) { await new MarvBotBusinessLayer(new DataAccess(new DatabaseContext())).SaveUserAcitivity(user, beforeChangeUser.Activity?.Name ?? "", afterChangeUser.Activity?.Name ?? ""); } } var beforeName = beforeChangeUser.Activity?.Name.Trim() ?? null; var afterName = afterChangeUser.Activity?.Name.Trim() ?? null; if (afterChangeUser.Activity != null) { if (beforeChangeUser.Activity != null) { if (beforeName == afterName) { return; } gameRole = guild.Roles.Where(x => x.ToString().Equals(beforeName) && !x.IsMentionable).FirstOrDefault(); await DeleteGameRoleAndVoiceChannel(guild, gameRole, user); gameRole = null; } gameRole = guild.Roles.Where(x => x.ToString().Equals(afterName) && !x.IsMentionable).FirstOrDefault(); if (gameRole == null) // if role does not exist, create it { gameRole = await guild.CreateRoleAsync(afterName, permissions : GuildPermissions.None, color : Color.Default, isHoisted : false, false); } var channel = guild.VoiceChannels.Where(x => x.ToString().Equals(gameRole.Name) && x.Bitrate == 96000).FirstOrDefault(); if (channel == null) { var properties = new VoiceChannelProperties { Bitrate = 96000 }; var altChannel = await guild.CreateVoiceChannelAsync(gameRole.Name); await altChannel.AddPermissionOverwriteAsync(guild.EveryoneRole, new OverwritePermissions(connect : PermValue.Deny, viewChannel : PermValue.Deny)); await altChannel.AddPermissionOverwriteAsync(gameRole, new OverwritePermissions(connect : PermValue.Allow, viewChannel : PermValue.Allow)); await altChannel.ModifyAsync(x => x.Bitrate = properties.Bitrate); //await user.ModifyAsync(x => x.Channel = altChannel); // Flyttar användaren } //else //{ // await user.ModifyAsync(x => x.Channel = altChannel); // Flyttar användaren //} await user.AddRoleAsync(gameRole); } else if (beforeChangeUser.Activity != null && afterChangeUser.Activity == null) { gameRole = guild.Roles.Where(x => x.ToString().Equals(beforeName) && !x.IsMentionable).FirstOrDefault(); if (gameRole == null) { return; } await DeleteGameRoleAndVoiceChannel(guild, gameRole, user); //Discord.Rest.RestVoiceChannel altChannel = null; //SocketVoiceChannel channel = guild.VoiceChannels.Where(input => input.ToString().Equals("General")).FirstOrDefault(); //if (channel == null) //{ // altChannel = await guild.CreateVoiceChannelAsync("General"); // await user.ModifyAsync(x => x.Channel = altChannel); //} //else //{ // await user.ModifyAsync(x => x.Channel = channel); //} } }
public static async Task <IVoiceChannel> GetOrCreateVoiceChannel(string name, ulong categoryId, SocketGuild guild) { return((IVoiceChannel)guild.VoiceChannels.FirstOrDefault(c => c.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) ?? await guild.CreateVoiceChannelAsync(name, properties => properties.CategoryId = categoryId)); }
private async static Task <Task> ReadyAsync() { Console.Clear(); Console.Title = $" Discord Raider | {_client.CurrentUser.Username}#{_client.CurrentUser.Discriminator}"; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); System.Threading.Thread.Sleep(4700); Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option ! (more option, write : EasterEGG and press enter)"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("___________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[1] Unban All (1.1) [4] Create mass text channel [7] Create mass voice channel [10] Unban Specific User "); Console.WriteLine("[2] DMALL [5] Give admin to all (1.1) [8] Rename all (1.1) [11] Twitch settings "); Console.WriteLine("[3] Delete all channel [6] List server [9] Ban all [12] Game settings "); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("____________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; string mas = Console.ReadLine(); if (mas == "EasterEGG") { Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("___________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Write : Credit"); Console.WriteLine("Write : ByStan"); Console.WriteLine("Write : ZelliDev"); Console.WriteLine("Write : Kirua"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("____________________________________________________________________________________________________________________"); Console.ReadKey(); await Program.ReadyAsync(); } if (mas == "Avaris") { await _client.SetGameAsync("A"); System.Threading.Thread.Sleep(1000); await _client.SetGameAsync("Av"); System.Threading.Thread.Sleep(1000); await _client.SetGameAsync("Ava"); System.Threading.Thread.Sleep(1000); await _client.SetGameAsync("Avar"); System.Threading.Thread.Sleep(1000); await _client.SetGameAsync("Avaris"); System.Threading.Thread.Sleep(1000); await Program.ReadyAsync(); } if (mas == "Zellidev") { Console.WriteLine("A candian programmer..."); await _client.SetGameAsync("Z"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("Ze"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("Zel"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("Zell"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("Zelly"); System.Threading.Thread.Sleep(900); await Program.ReadyAsync(); } if (mas == "Kirua") { Console.WriteLine("My Friend"); await _client.SetGameAsync("K"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("Ki"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("Kir"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("Kiru"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("Kirua"); System.Threading.Thread.Sleep(900); await Program.ReadyAsync(); } if (mas == "ByStan") { await _client.SetGameAsync("S"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("St"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("Sta"); System.Threading.Thread.Sleep(900); await _client.SetGameAsync("Stan"); System.Threading.Thread.Sleep(900); var fileStream = new FileStream(Directory.GetCurrentDirectory() + "/Stan.png", FileMode.Open); var image = new Image(fileStream); await _client.CurrentUser.ModifyAsync(u => u.Avatar = image); await Program.ReadyAsync(); } if (mas == "Credit") { Console.WriteLine("Devloppement : By Stanley#0001"); Console.WriteLine("Design : By Stanley#0001"); } if (mas == "12") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[12] Game settings"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Wath is the game you wanna set? "); string name = Console.ReadLine(); await _client.SetGameAsync(name); await Program.ReadyAsync(); } if (mas == "11") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[11] Twitch settings"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Que regardez vous ?"); string a = Console.ReadLine(); Console.WriteLine("Le lien twitch ?"); string b = Console.ReadLine(); await _client.SetGameAsync(a, b, StreamType.Twitch); await Program.ReadyAsync(); } if (mas == "10") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[10] Unban Specific User"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Guild ID : "); string guildid2 = Console.ReadLine(); ulong id = Convert.ToUInt64(guildid2); Console.Write("User ID : "); string userID = Console.ReadLine(); ulong userid = Convert.ToUInt64(userID); SocketGuild guild = _client.GetGuild(id); foreach (SocketUser user in guild.Users) { try { await guild.RemoveBanAsync(userid); } catch (Exception) { } } await Program.ReadyAsync(); } if (mas == "9") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[9] Ban all"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Guild ID : "); string guildid2 = Console.ReadLine(); ulong id = Convert.ToUInt64(guildid2); SocketGuild guild = _client.GetGuild(id); foreach (SocketUser user in guild.Users) { try { await guild.AddBanAsync(user, 0, "Using Stanraid"); } catch (Exception) { } } await Program.ReadyAsync(); } if (mas == "8") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[8] ???????"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; await Program.ReadyAsync(); } if (mas == "7") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[7] Create mass voice channel"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Server ID : "); string guildid2 = Console.ReadLine(); Console.Write("Voice Channel Name : "); string textchan = Console.ReadLine(); ulong id = Convert.ToUInt64(guildid2); SocketGuild guild = _client.GetGuild(id); for (int i = 0; i < 100; i++) { try { await guild.CreateVoiceChannelAsync(textchan.Replace(' ', '-')); } catch (Exception) { } } await Program.ReadyAsync(); } if (mas == "6") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[6] List Server"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; foreach (var guild in _client.Guilds) { Console.WriteLine("+ Name : " + guild.Name + " | ID : " + guild.Id + " | Owner : " + guild.Owner); } Console.ReadKey(); await Program.ReadyAsync(); } if (mas == "5") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[5] ???????"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; await Program.ReadyAsync(); } if (mas == "4") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[4] Create mass text channel"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Server ID : "); string guildid2 = Console.ReadLine(); Console.Write("Text Channel Name : "); string textchan = Console.ReadLine(); ulong id = Convert.ToUInt64(guildid2); SocketGuild guild = _client.GetGuild(id); for (int i = 0; i < 100; i++) { try { await guild.CreateTextChannelAsync(textchan.Replace(' ', '-')); } catch (Exception) { } } await Program.ReadyAsync(); } if (mas == "3") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[3] Delete all channel"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Guild ID : "); string guildid2 = Console.ReadLine(); ulong id = Convert.ToUInt64(guildid2); SocketGuild guild = _client.GetGuild(id); foreach (SocketTextChannel chan in guild.TextChannels) { try { await chan.DeleteAsync(); } catch (Exception) { } } foreach (SocketVoiceChannel chanv in guild.VoiceChannels) { try { await chanv.DeleteAsync(); } catch (Exception) { } } await Program.ReadyAsync(); } if (mas == "2") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[2] DMALL"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; Console.Write("DMALL Message : "); string DMALL2 = Console.ReadLine(); foreach (SocketGuild guild in _client.Guilds) { foreach (SocketUser user in guild.Users) { try { await user.SendMessageAsync(DMALL2); } catch (Exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Cannot send : 1 : message"); } } await Program.ReadyAsync(); } } if (mas == "1") { Console.Clear(); Console.WriteLine("Login succes : " + _client.CurrentUser.Username + "#" + _client.CurrentUser.Discriminator); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\t\r\n\t ████████ ██████████ ██████ ██ ██ ████████ ██████ ██ ██████ ██████ ████████\r\n\t ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ██████ ██ ██████ ████████ ████████ ██████ ██ ██ ██ ████ ████████\r\n\t ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\r\n\t ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██\r\n\t\t\t\tBy Stanley & Rataka"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Hi " + _client.CurrentUser.Username + " This is the raid option !"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("[1] Leave"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Leave message : "); } return(Task.CompletedTask); }
public async Task IsolerAsync(IGuildUser iuser) { if (Context.Guild.GetCategoriesAsync().Result.Where(x => x.Id == Config._INSTANCE.GuildConfigs[Context.Guild.Id].IsolementCategoryVoiceChannelId).Count() == 0) { var _settings = new Settings(); await ReplyAsync("La catégorie du salon d'isolement n'est pas définie. Remédiez-y avec la commande **x!settings IsolementCategoryVoiceChannelId**."); await ReplyAsync("N'oubliez pas d'ajouter des salons interdits aux utilisateurs en période d'isolement ! (**x!settings AddForbiddenIsolementChannelId**)"); return; } SocketGuildUser user = (SocketGuildUser)iuser; if (user.IsBot || user.IsWebhook) { await ReplyAsync("Vous ne pouvez isoler que des joueurs. Tu ne comptais tout de même pas m'isoler j'éspère ?!"); return; } if (user == null) { await ReplyAsync("Le joueur ciblé n'existe pas."); return; } if (user.VoiceChannel == null) { await ReplyAsync(user.Mention + " n'est pas connecté à un serveur vocal."); return; } SocketGuild guild = user.Guild; SocketChannel isolementChannel = Program._client.GetChannel(Config._INSTANCE.GuildConfigs[Context.Guild.Id].IsolementVoiceChannelId); if (isolementChannel == null) { await ReplyAsync("Création d'une nouvelle cellule d'isolement."); ICategoryChannel category = Program._client.GetGuild(guild.Id).CategoryChannels .FirstOrDefault(x => x.Id == Config._INSTANCE.GuildConfigs[Context.Guild.Id].IsolementCategoryVoiceChannelId); RestVoiceChannel rest = await guild.CreateVoiceChannelAsync("isolement"); await rest.ModifyAsync(x => x.CategoryId = category.Id); Config._INSTANCE.GuildConfigs[Context.Guild.Id].IsolementVoiceChannelId = rest.Id; XmlManager.SaveXmlConfig(); } try { foreach (ulong forbiddenId in Config._INSTANCE.GuildConfigs[Context.Guild.Id].ForbiddenIsolementChannelsId) { await guild.GetChannel(forbiddenId).AddPermissionOverwriteAsync(user, new OverwritePermissions(0, 13631488)); } } catch { } await user.ModifyAsync(x => x.ChannelId = Config._INSTANCE.GuildConfigs[Context.Guild.Id].IsolementVoiceChannelId); await ReplyAsync(user.Mention + " est désormais seul, au bord du suicide."); joueursIsolés.Add(user.Id, user.VoiceChannel.Id); System.Threading.Timer timer = null; timer = new System.Threading.Timer(async(obj) => { await Task.Run(() => LibreAsync(user, true, true)); timer.Dispose(); }, null, (int)(Config._INSTANCE.GuildConfigs[Context.Guild.Id].IsolementTime * 1000), System.Threading.Timeout.Infinite); }