Exemple #1
0
        public async Task RoleAssignment(DiscordMessage msgInv, CommandContext e, List <DiscordMember> players)
        {
            try
            {
                // Création de tous les channels sans Droit
                var chsPerso = await Global.Game.Guild
                               .CreateChannelAsync(Global.Game.Texts.Channels.PersoGroup, ChannelType.Category);

                Global.Game.DiscordChannels.Add(GameChannel.PersoGroup, chsPerso);

                var wolfGrpChannel =
                    await Global.Game.Guild.CreateChannelAsync(Global.Game.Texts.Channels.WolvesChannel,
                                                               ChannelType.Category);

                var townGrpChannel = await Global.Game.Guild
                                     .CreateChannelAsync(Global.Game.Texts.Channels.TownChannel, ChannelType.Category);


                var townTChannel =
                    await Guild.CreateChannelAsync(Texts.Channels.TownChannel, ChannelType.Text, townGrpChannel);

                var townVChannel =
                    await Guild.CreateChannelAsync(Texts.Channels.TownChannel, ChannelType.Voice, townGrpChannel);

                DiscordChannels.Add(GameChannel.TownText, townTChannel);
                DiscordChannels.Add(GameChannel.TownVoice, townVChannel);


                var wolfTChannel =
                    await Guild.CreateChannelAsync(Texts.Channels.WolvesChannel, ChannelType.Text, wolfGrpChannel);

                var wolfVChannel =
                    await Guild.CreateChannelAsync(Texts.Channels.WolvesChannel, ChannelType.Voice, wolfGrpChannel);

                DiscordChannels.Add(GameChannel.WolfText, wolfTChannel);
                DiscordChannels.Add(GameChannel.WolfVoice, wolfVChannel);

                var graveyardGrpChannel =
                    await Guild.CreateChannelAsync(Texts.Channels.GraveyardChannel, ChannelType.Category);

                var graveyardTChannel = await Guild.CreateChannelAsync(Texts.Channels.GraveyardChannel,
                                                                       ChannelType.Text, graveyardGrpChannel);

                var graveyardVChannel = await Guild.CreateChannelAsync(Texts.Channels.GraveyardChannel,
                                                                       ChannelType.Voice, graveyardGrpChannel);

                await graveyardTChannel.AddOverwriteAsync(Global.Roles[PublicRole.Spectator], GameBuilder.UsrPerms);

                DiscordChannels.Add(GameChannel.GraveyardText, graveyardTChannel);
                DiscordChannels.Add(GameChannel.GraveyardVoice, graveyardVChannel);

                foreach (var discordMember in Guild.Members)
                {
                    if (discordMember.Roles.Contains(Global.Roles[PublicRole.Spectator]))
                    {
                        await graveyardVChannel.AddOverwriteAsync(discordMember,
                                                                  GameBuilder.CreatePerms(Permissions.UseVoiceDetection, Permissions.UseVoice,
                                                                                          Permissions.Speak));
                    }
                }

                await GameBuilder.CreatePersonnages(players);

                await(await e.Channel.GetMessageAsync(msgInv.Id)).ModifyAsync((await townTChannel.CreateInviteAsync())
                                                                              .ToString());

                Global.Client.MessageReactionAdded   += GameBuilder.Spectator_ReactionAdd;
                Global.Client.MessageReactionRemoved += GameBuilder.Spectator_ReactionRem;
            }
            catch (SystemException ex)
            {
                Console.WriteLine(ex);
            }
        }