Esempio n. 1
0
        private async Task ReactionAdded(Cacheable <IUserMessage, ulong> ch, ISocketMessageChannel chanel, SocketReaction reaction)
        {
            IUserMessage msg = await ch.GetOrDownloadAsync();

            if (msg == null)
            {
                return;
            }

            if (QuoteModule._trackedQuoteList.Keys.Contains(msg.Id) && !reaction.User.Value.IsBot)
            {
                if (reaction.Emote.Name == "✅")
                {
                    await chanel.DeleteMessageAsync(msg.Id);

                    QuoteModule._trackedQuoteList.Remove(msg.Id);
                }
                else
                {
                    //add to file
                    File.AppendAllLines(fileName, new string[] { QuoteModule._trackedQuoteList[msg.Id].Id.ToString() });
                    await chanel.DeleteMessageAsync(msg.Id);

                    QuoteModule._trackedQuoteList.Remove(msg.Id);
                }
            }

            if (reaction.Emote.Name == "💬" && !msg.Author.IsBot)
            {
                try {
                    await QuoteModule.BotAddQuote(_services.GetService <IQouteRepository>(),
                                                  _services.GetService <IScoreRepository>(), _services.GetService <IUserRepository>(),
                                                  chanel, msg.Content, msg.Id, reaction.User.GetValueOrDefault(null) as IGuildUser
                                                  , msg.Author as IGuildUser, msg.Timestamp.DateTime);
                }
                catch (Exception e) {
                    if (e.GetType().Equals(typeof(QuotingYourselfException)))
                    {
                        await msg.Channel.SendMessageAsync("A bit narcissistic to quote yourself, no?");
                    }
                    else
                    {
                        await EmbedBuilderFunctions.UnhandledException(e.Message, msg.Channel as ISocketMessageChannel);
                    }
                }
            }
        }
Esempio n. 2
0
        private async Task SendException(string ex, ISocketMessageChannel channel)
        {
            switch (ex)
            {
            case "There are no quotes in the server, Wow quote more losers":
                await channel.SendMessageAsync(ex);

                break;

            case "Empty Quote":
                await channel.SendMessageAsync("What's the point in adding something empty huh?");

                break;

            case "We couldn't find the user":
                await channel.SendMessageAsync("I couldn't find this user, are you sure it's not an imaginary friend?");

                break;

            case "No quotes found":
                await channel.SendMessageAsync("This user has no quotes, wow talk more loser.");

                break;

            case "we couldn't find the quote":
                await channel.SendMessageAsync("I couldn't find the quote you're looking for.");

                break;

            case "Image not found":
                await channel.SendMessageAsync("I couldn't find any images matching your request, sorry chap...");

                break;

            case "We couldn't find a location":
                await channel.SendMessageAsync("We couldn't find the location, or perhaps you were searching for Birmingham ya drugie.");

                break;

            case "word already banned":
                await channel.SendMessageAsync("Banning a word twice won't unban it ;) ");

                break;

            case "There is no location set":
                await channel.SendMessageAsync("You don't have a location set you dummy, " +
                                               $"use the command `{prefix}weather set`");

                break;

            case "word not banned":
                await channel.SendMessageAsync($"This word is not in the banlist. To view the list use `{prefix}banword list`");

                break;

            case "You're trying to quote yourself":
                await channel.SendMessageAsync("A bit narcissistic to quote yourself, no?");

                break;

            default:
                await EmbedBuilderFunctions.UnhandledException(ex, channel);

                break;
            }
        }