示例#1
0
        public async Task CreateDungeon()
        {
            DungeonManager manager = new DungeonManager();
            GuildConfig    config  = new GuildConfig(Context.Guild.Id.ToString());

            config.CheckForFile();
            config = config.Load() as GuildConfig;

            if (config.DungeonChannelID != Context.Channel.Id)
            {
                await ReplyAsync("*Command not ran in dungeon, creating dungeon in this channel...*");

                config.DungeonChannelID = Context.Channel.Id;
            }

            var monsterMessage = await ReplyAsync(embed : manager.GenerateMonsterCard(Context));

            config.DungeonMessageID = monsterMessage.Id;

            await monsterMessage.AddReactionsAsync(DungeonManager.EMOTES);

            var combatMessage = await ReplyAsync($"```{config.DungeonCombatLog}```");

            config.DungeonCombatID = combatMessage.Id;

            config.Save();
        }
示例#2
0
        private async Task ReactionAddedEvent(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            IUserMessage    msg  = message.DownloadAsync().Result;
            SocketGuildUser user = await channel.GetUserAsync(reaction.UserId) as SocketGuildUser;

            SocketGuild    guild   = user.Guild;
            DungeonManager manager = new DungeonManager();

            GuildConfig config = new GuildConfig(guild.Id.ToString());

            config.CheckForFile();
            config = config.Load() as GuildConfig;

            if (config.DungeonChannelID != channel.Id || config.DungeonMessageID != message.Id ||
                user.IsBot)
            {
                return;
            }

            // Check if valid emote
            for (int i = 0; i < DungeonManager.EMOTES.Length; i++)
            {
                if (DungeonManager.EMOTES[i].Equals(reaction.Emote))
                {
                    break;
                }
                else if (i == DungeonManager.EMOTES.Length - 1)
                {
                    return;
                }
            }

            Embed newEmbed = manager.RefreshMonsterCard(msg.Embeds.First(), guild, user);
            await msg.ModifyAsync(x => x.Embed = newEmbed);

            await msg.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
        }