private static async Task AddCategoryWithChannels(SocketGuild guild, IRole memberRole, string categoryName, int position) { RestCategoryChannel category = await guild.CreateCategoryChannelAsync(categoryName, properties => properties.Position = position); await category.AddPermissionOverwriteAsync(guild.EveryoneRole, OverwritePermissions.InheritAll); await category.AddPermissionOverwriteAsync(memberRole, OverwritePermissions.InheritAll); //Text chat RestTextChannel chat = await guild.CreateTextChannelAsync(categoryName.ToLower(), properties => properties.CategoryId = category.Id); await chat.SyncPermissionsAsync(); //Auto VC chat RestVoiceChannel autoVcChat = await AutoVCChannelCreator.CreateAutoVCChannel(guild, categoryName); await autoVcChat.ModifyAsync(properties => properties.CategoryId = category.Id); await autoVcChat.SyncPermissionsAsync(); }
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; }); } }
internal async Task UpdateTime(int seconds) { TimeSpan ts = TimeSpan.FromSeconds(seconds); string timefromsec = ""; if (ts.Days != 0) { timefromsec += $"{ts.Days} Days, "; } if (ts.Hours != 0) { timefromsec += $"{ts.Hours} Hours, "; } if (ts.Minutes != 0) { timefromsec += $"{ts.Minutes} Minutes"; } if (ts.Seconds != 0) { if (ts.Minutes != 0) { timefromsec += $", and {ts.Seconds} Seconds"; } else { timefromsec += $"{ts.Seconds} Seconds"; } } await chantimer.ModifyAsync(x => x.Name = $"Time: {timefromsec}"); EmbedBuilder eb = new EmbedBuilder(); eb.Title = "GIVEAWAY"; eb.Color = Color.Blue; eb.Description = $"{_client.GetGuild(SwissGuildId).GetUser(currgiveaway.GiveAwayUser).Mention} Has started a giveaway for **{currgiveaway.GiveAwayItem}** with {currgiveaway.numWinners} winners, to enter the giveaway join {currgiveaway.discordInvite}\n\n **How does it work?** \n after the timer reaches 0 everyone will get access to the \"ban command, its like a FFA. the last person(s) remaining will get the giveaway item \n \n ***GIVEAWAY STARTS IN {timefromsec} ({seconds} seconds)***"; await currgiveaway.giveawaymsg.ModifyAsync(x => x.Embed = eb.Build()); }
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); }
public async Task StartGameAsync() { AudioModule am = new AudioModule((AudioService)Program._services.GetService(typeof(AudioService)), Context); try { if (mainVoiceChannel != null) { await mainVoiceChannel.ModifyAsync(x => x.Name = "Joueurs du JDR"); } if (allPlayers.Count > 0) { // Calcul d'aléatoire de début de partie pour le pistolet if (map != null) { map.PistolPossible(1); } else { Console.WriteLine("Aucune map crée"); } // Placement du talisman dans la première salle var random = r.NextDouble(); if (random <= 1) { map.allStructures.OfType <Room>().First().SetTalisman(true); Console.WriteLine("La structure " + map.allStructures.OfType <Room>().First().id + " possède le talisman"); } // On renomme la dernière salle en salle finale var lastRoom = map.allStructures.OfType <Room>().Last(); lastRoom.illustration.Title = lastRoom.illustration.Title + " (Salle finale)"; hasStarted = true; // Entrée du batiment Console.WriteLine("Nombre de structures " + map.allStructures.Count); if (currentStructureID == 0) { string introTxt = "Intro"; EmbedBuilder eb = new EmbedBuilder { Title = "Temple Maya - " + allPlayers.Count + " joueurs", Description = introTxt, ImageUrl = "https://s-media-cache-ak0.pinimg.com/originals/f0/73/06/f07306ec3a8f66709791aaadf8cc77c1.jpg" }; await ReplyAsync("", false, eb); } // Parcours des salles for (int id = 0; id < map.allStructures.Count; id++) { // Thread.Sleep(10000); await _context.Channel.SendMessageAsync("On passe à la structure suivante / NOUVELLE ITERATION"); Console.WriteLine("Structure actuelle" + id); if (map.allStructures[id].GetType() == typeof(Room) && id != map.allStructures.Count - 1) { await ProposeAbilityUse(); Console.WriteLine("Sortie de ProposeAbilityUse()"); // Thread.Sleep(10000); Console.WriteLine("Pièce de type salle"); // On montre la salle await ReplyAsync("Calculs de probabilités pour la Salle"); var room = (map.allStructures[id] as Room); await room.ShowIllustration(Context); // On regarde et on assigne un pistolet await CheckPistol(room); // L'esprit Maya demande si on sacrifie un joueur await ProposeSacrifice(); Thread.Sleep(10000); // On choisit le passage await room.ChoosePassage(Context, currentStructureID, map, am); currentRoomID++; } else // Sinon on prend le passage { await ReplyAsync("Calculs de probabilités pour le passage"); var pass = map.allStructures[currentStructureID]; await pass.ShowIllustration(Context); // On affiche l'ordre de passage en mélangeant la liste des joueurs await ReplyAsync("__ Ordre de passage __ "); var randomizedPlayers = allPlayers.OrderBy(x => r.Next()).ToList(); string playerList = string.Empty; foreach (var p in randomizedPlayers) { playerList += p.user.Username; if (p != randomizedPlayers.Last()) { playerList += " :arrow_right: "; } } await ReplyAsync(playerList); if (pass.allTraps.Count > 0) { await ReplyAsync(":skull: Vous avez repéré " + pass.allTraps.Count + " piège pour ce passage"); foreach (var trap in pass.allTraps) { await trap.ShowIllustration(Context); for (int i = 0; i < randomizedPlayers.Count; i++) { await ReplyAsync((i + 1) + " ) " + randomizedPlayers[i].user.Username + " passe à travers le piège..."); await trap.PlayerWalkOnMe(randomizedPlayers[i], Context); if (deadPlayers.Contains(randomizedPlayers[i])) { await ReplyAsync(randomizedPlayers[i].user.Mention + " vient de mourrir !!\n :information_source: Le piège est maintenant désactivé"); } if (randomizedPlayers.Count == 0) { await ReplyAsync("JDR terminé, tout le monde est mort"); } } } } } currentStructureID++; } // Sortie du batiment if (currentStructureID == map.allStructures.Count) { string outroTxt = "Outro"; EmbedBuilder eb = new EmbedBuilder { Title = "Temple Maya - " + allPlayers.Count + " joueurs", Description = outroTxt, ImageUrl = "http://moonshineink.com/sites/default/files/so_a_offroad_multiplejeeps.tiff_web.jpg" }; await ReplyAsync("Tableau récapitulatif", false, eb); var jdrPlayers = new List <Player>(); List <Player> deadAndAlivePlayers = new List <Player>(); deadAndAlivePlayers = Enumerable.Union(allPlayers, deadPlayers).ToList(); } } else { await ReplyAsync(":warning: Un moins un joueur doit être inscrit pour commencer la partie"); } } catch (Exception ex) { hasStarted = false; await Console.Out.WriteLineAsync("Erreur JDR:" + ex); } }