public async Task <bool> HandleMessageAsync(IMessage message)
        {
            ResponsiveMessageInfo info = messages.GetOrDefault(message.Author.Id);

            if (info != null && message.Channel.Id == info.Context.Channel.Id)
            {
                Messaging.IMessage responseMessage = new Message(message.Content)
                {
                    Attachments = message.Attachments.Select(attachment => new Messaging.Attachment()
                    {
                        Url = attachment.Url, Filename = attachment.Filename
                    })
                };

                info.Response = new ResponseMessageResponse(responseMessage, info.AllowCancellation && message.Content.Equals(CancellationString, StringComparison.OrdinalIgnoreCase));

                RemoveMessageInfo(message.Author.Id);

                info.Waiter.Set();

                return(await Task.FromResult(true));
            }

            return(await Task.FromResult(false));
        }
Ejemplo n.º 2
0
        public static async Task DeleteMessage(this IMessage msg)
        {
            var ms = msg as IUserMessage;

            try {
                await ms.DeleteAsync();
            }
            catch (Discord.Net.HttpException e) {
                if (e.HttpCode == System.Net.HttpStatusCode.NotFound)
                {
                    Console.WriteLine("The original message was deleted");
                }
            }
        }
Ejemplo n.º 3
0
        public static async Task AddNavigations(this IMessage msg, int indx, int maxLength)
        {
            var ms = msg as IUserMessage;

            if (indx != 0)
            {
                await ms.AddReactionAsync(new Emoji("⬅"));
            }

            if (indx != maxLength - 1)
            {
                await ms.AddReactionAsync(new Emoji("➡"));
            }
        }
Ejemplo n.º 4
0
        public Message(Discord.IMessage message)
        {
            Content = message.Content;
            Channel = new Channel(message.Channel);

            if (message.Author is IGuildUser guildUser)
            {
                User = new ServerUser(guildUser);
            }
            else
            {
                User = new User(message.Author);
            }
        }
Ejemplo n.º 5
0
        private async Task DeletedMessage(Cacheable <IMessage, ulong> arg1, ISocketMessageChannel arg2)
        {
            Discord.IMessage mess = arg2 as IMessage;

            SetText(DateTime.Now.ToString("h:mm:ss tt") + "[EVENT:MessageDeleted] : Le message " + arg1.Id.ToString() + " par " + mess.Author.Username + "#" + mess.Author.Discriminator.ToString());
        }