コード例 #1
0
        public async Task Remove([Name("Queue name"), Summary("Optional, if empty the !clear command will be used."), Remainder] string queueName = "")
        {
            if (!PickupHelpers.IsInPickupChannel((IGuildChannel)Context.Channel))
            {
                return;
            }

            queueName = queueName.Trim(' ', '"').Trim();

            if (string.IsNullOrWhiteSpace(queueName))
            {
                await Clear();

                return;
            }

            //find queue with name {queueName}
            var queue = await _miscCommandService.VerifyQueueByName(queueName, (IGuildChannel)Context.Channel);

            if (queue == null)
            {
                return;
            }

            await _subscriberCommandService.Leave(queue, Context.Channel, (IGuildUser)Context.User, messageReference : Context.Message.Reference);
        }
コード例 #2
0
        private async Task ReactionRemoved(Cacheable <IUserMessage, ulong> message, Cacheable <IMessageChannel, ulong> channel, SocketReaction reaction)
        {
            if (channel.Value == null)
            {
                await channel.GetOrDownloadAsync();
            }

            if (channel.Value is not IGuildChannel guildChannel || guildChannel.Name != ChannelNames.ActivePickups)
            {
                return;
            }
            if (reaction.User.Value.IsBot)
            {
                return;
            }

            if (reaction.Emote.Name == "\u2705")
            {
                var queue = await _queueRepository.FindQueueByMessageId(reaction.MessageId, guildChannel.GuildId.ToString());

                if (queue != null)
                {
                    var pickupChannel = ((SocketGuild)guildChannel.Guild).Channels.FirstOrDefault(c => c.Name.Equals(ChannelNames.Pickup)) as SocketTextChannel;
                    await _subscriberCommandService.Leave(queue, pickupChannel ?? (SocketTextChannel)guildChannel,
                                                          (SocketGuildUser)reaction.User);
                }
            }
        }