Пример #1
0
        public async Task OnReady()
        {
            SetupGeneral();

            await GeneralHandler.UpdateRoleMessage();  // fix the role selection message on startup

            Ready = true;
            KLog.Important("Ready!");
        }
Пример #2
0
        public override async Task PerformAction(SocketReaction option)
        {
            string opt = option.Emote.ToString();

            switch (opt)
            {
            case ReactionHandler.CHECK_STR:
                if (Emote == BotUtils.ZeroSpace || Emote == EmptyOrInvalidEmote)
                {
                    Emote = EmptyOrInvalidEmote;
                    await UpdateEmbed();

                    return;
                }

                if (ReactionHandler.RoleMap.ContainsKey(Emote))
                {
                    if (ServerData.Server.GetRole(ReactionHandler.RoleMap[Emote]) == null)
                    {
                        ulong id = ReactionHandler.RoleMap[Emote];

                        ReactionHandler.RoleMap.Remove(Emote);
                        ReactionHandler.SaveRoleMap();

                        EventQueueManager.RemoveEvent(this);
                        await ReactionHandler.CloseActionEmbedAsync(this);

                        await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Something went wrong! Please use the command again!"));

                        KLog.Info($"[REE] Role was null! ID: {id}");
                        return;
                    }

                    Emote = $"The role {ServerData.Server.GetRole(ReactionHandler.RoleMap[Emote]).Mention} already has that emote!";
                    await UpdateEmbed();

                    break;
                }

                if (ServerData.Server.GetRole(Role.Id) == null)
                {
                    ulong id = ReactionHandler.RoleMap[Emote];

                    EventQueueManager.RemoveEvent(this);
                    await ReactionHandler.CloseActionEmbedAsync(this);

                    await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Something went wrong! Please use the command again!"));

                    KLog.Info($"[REE] Role was null! ID: {id}");
                    return;
                }

                ReactionHandler.RoleMap.Add(Emote, Role.Id);
                ReactionHandler.SaveRoleMap();

                await GeneralHandler.UpdateRoleMessage();

                EventQueueManager.RemoveEvent(this);
                await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Emote Association Added."));

                await Message.DeleteAsync();

                break;

            case ReactionHandler.DECLINE_STR:
                EventQueueManager.RemoveEvent(this);
                await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Action Canceled."));

                await Message.DeleteAsync();

                break;

            default:
                Emote = option.Emote.ToString();
                await UpdateEmbed();

                break;
            }
        }