Exemple #1
0
        //TODO: reduce this function
        public async Task HandleMessage(string mention, ResponseAwaiter response, ulong callerId, ulong callingChannelId, SocketCommandContext ctx)
        {
            var id     = Regex.Replace(mention, @"[^\d]", "");
            var result = await response.GetResponseFromUser(callerId, callingChannelId);

            if (!result.HasErrors)
            {
                var allUsers = ctx.Guild.Users.ToList();
                var channels = ctx.Guild.Channels.ToList();

                var channelMention = result.Data;
                var channel        = channels.FirstOrDefault(x => x.Name == channelMention);

                if (channel != null)
                {
                    var userFound = allUsers.FirstOrDefault(x => x.Id.ToString() == id);

                    if (userFound != null)
                    {
                        if (channel.Users.Contains(userFound))
                        {
                            var textChannel = (ITextChannel)channel;
                            await textChannel.SendMessageAsync(Quips.GetRandomQuip(userFound.Mention));
                        }
                        else
                        {
                            await ctx.Channel.SendMessageAsync($"{channel.Name} does not contain that user...");
                        }
                    }
                    else
                    {
                        await ctx.Channel.SendMessageAsync($"**The Musk** could not locate that user - {mention}.");
                    }
                }
                else
                {
                    await ctx.Channel.SendMessageAsync("Do not try to fool the Musk. That channel is nonexistent.");
                }
            } //else time-out occured
        }
Exemple #2
0
 public async Task QouteAsync()
 {
     await ReplyAsync(Quips.GetRandomQuip());
 }