コード例 #1
0
ファイル: AddAdminEmbed.cs プロジェクト: DavidXLiu/Kamtro-Bot
        public override async Task PerformAction(SocketReaction option)
        {
            switch (option.Emote.ToString())
            {
            case ReactionHandler.CHECK_STR:
                Program.Settings.AdminUsers.Add(User.Id);
                Program.Settings.SaveJson();

                await Context.Channel.SendMessageAsync(BotUtils.KamtroText($"Added user {BotUtils.GetFullUsername(User)} as an admin."));

                KLog.Important($"User {BotUtils.GetFullUsername(User)} added as an admin");

                EventQueueManager.RemoveEvent(this);
                await Message.DeleteAsync();

                break;

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

                await Message.DeleteAsync();

                break;
            }
        }
コード例 #2
0
        public override async Task PerformAction(SocketReaction option)
        {
            string number = option.Emote.ToString();

            if (NUMBERS.Contains(number))
            {
                int chosenIndex = Numbers.IndexOf(number);

                if (chosenIndex >= 0 && chosenIndex <= 10)
                {
                    // if the index is valid
                    SocketGuildUser su = UserOptions[chosenIndex];

                    if (hasContext)
                    {
                        // If this is the type of embed that needs context
                        await selectedActionWithContext(su, Context); // Call the context method
                    }
                    else
                    {
                        await selectedAction(su); // Call the method passed in.
                    }

                    EventQueueManager.RemoveEvent(this); // Remove it from the queue
                    if (Channel == null)
                    {
                        return;
                    }
                    await Channel.DeleteMessageAsync(Message);
                }
            }
        }
コード例 #3
0
ファイル: HackedEmbed.cs プロジェクト: DavidXLiu/Kamtro-Bot
        public async override Task PerformAction(SocketReaction option)
        {
            if (option.Emote.ToString() == ReactionHandler.CHECK_STR)
            {
                await Hacked();
            }

            EventQueueManager.RemoveEvent(this);
        }
コード例 #4
0
ファイル: NSFWEmbed.cs プロジェクト: DavidXLiu/Kamtro-Bot
        public async override Task PerformAction(SocketReaction option)
        {
            switch (option.Emote.ToString())
            {
            case CHECK:
                await option.Channel.SendMessageAsync(BotUtils.KamtroText("You can now see the lewd owo"));

                EventQueueManager.RemoveEvent(this);

                await BotUtils.GetGUser(Context).AddRoleAsync(ServerData.NSFWRole);

                break;

            case DECLINE:
                await option.Channel.SendMessageAsync(BotUtils.KamtroText("Understood."));

                EventQueueManager.RemoveEvent(this);
                break;
            }
        }
コード例 #5
0
        public override async Task PerformAction(SocketReaction option)
        {
            string number = option.Emote.ToString();

            if (NUMBERS.Contains(number))
            {
                int chosenIndex = Numbers.IndexOf(number);

                if (chosenIndex >= 0 && chosenIndex <= 10)
                {
                    await SelectedAction(Options[chosenIndex]); // Call the method passed in.
                }

                EventQueueManager.RemoveEvent(this); // Remove it from the queue
                if (Context.Channel == null)
                {
                    return;
                }
                await Context.Channel.DeleteMessageAsync(Message);
            }
        }
コード例 #6
0
        public override async Task PerformAction(SocketReaction option)
        {
            switch (option.Emote.ToString())
            {
            case ReactionHandler.CHECK_STR:
                await Action(true);

                EventQueueManager.RemoveEvent(this);
                await Message.DeleteAsync();

                break;

            case ReactionHandler.DECLINE_STR:
                await Action(false);

                EventQueueManager.RemoveEvent(this);
                await Message.DeleteAsync();

                break;
            }
        }
コード例 #7
0
        public async override Task PerformAction(SocketReaction option)
        {
            switch (option.Emote.ToString())
            {
            case MODIFY:
                kamtroText = !kamtroText;
                await Message.ModifyAsync(x => x.Embed = GetEmbed());

                break;

            case END:
                if (targetChannel != null)
                {
                    await option.Channel.SendMessageAsync(BotUtils.KamtroText($"You will no longer send messages to {targetChannel.Name}."));
                }
                else if (targetUser != null)
                {
                    await option.Channel.SendMessageAsync(BotUtils.KamtroText($"You will no longer send messages to {targetUser.Username}#{targetUser.Discriminator}."));
                }
                EventQueueManager.RemoveEvent(this);
                break;
            }
        }
コード例 #8
0
        public override async Task ButtonAction(SocketReaction action)
        {
            switch (action.Emote.ToString())
            {
            case ReactionHandler.CHECK_STR:
                if (Remove)
                {
                    await RemRole();
                }
                else
                {
                    await AddRole();
                }

                Program.ReloadConfig();

                EventQueueManager.RemoveEvent(this);
                await Message.DeleteAsync();

                break;

            case ReactionHandler.DECLINE_STR:
                if (Remove)
                {
                    await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Role deletion has been cancelled."));
                }
                else
                {
                    await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Role addition has been cancelled."));
                }

                EventQueueManager.RemoveMessageEvent(this);
                await Context.Channel.DeleteMessageAsync(Message);

                break;
            }
        }
コード例 #9
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;
            }
        }