Пример #1
0
        /// <summary>
        ///     Determines whether the specified emote is equal to the current emote.
        /// </summary>
        /// <param name="other">The object to compare with the current object.</param>
        public override bool Equals(object other)
        {
            if (other == null)
            {
                return(false);
            }
            if (other == this)
            {
                return(true);
            }

            Emote otherEmote = other as Emote;

            if (otherEmote == null)
            {
                return(false);
            }

            return(Id == otherEmote.Id);
        }
Пример #2
0
        public static bool TryParse(string text, out Emote result)
        {
            result = null;
            if (text.Length >= 4 && text[0] == '<' && text[1] == ':' && text[text.Length - 1] == '>')
            {
                int splitIndex = text.IndexOf(':', 2);
                if (splitIndex == -1)
                {
                    return(false);
                }

                if (!ulong.TryParse(text.Substring(splitIndex + 1, text.Length - splitIndex - 2), NumberStyles.None, CultureInfo.InvariantCulture, out ulong id))
                {
                    return(false);
                }

                string name = text.Substring(2, splitIndex - 2);
                result = new Emote(id, name);
                return(true);
            }
            return(false);
        }
Пример #3
0
 /// <summary>
 /// Converts an existing <see cref="Emote"/> to an abstracted <see cref="IEmoteEntity"/> value.
 /// </summary>
 /// <param name="emote">The existing <see cref="Emote"/> to be abstracted.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="emote"/>.</exception>
 /// <returns>An <see cref="IEmoteEntity"/> that abstracts <paramref name="emote"/>.</returns>
 public static IEmoteEntity Abstract(this Emote emote)
 => emote switch
 {
     null
     => throw new ArgumentNullException(nameof(emote)),
Пример #4
0
 /// <inheritdoc cref="Emote.ToString" />
 public override string ToString()
 => Emote.ToString();
Пример #5
0
 /// <inheritdoc cref="Emote.GetHashCode" />
 public override int GetHashCode()
 => Emote.GetHashCode();
Пример #6
0
 /// <inheritdoc cref="Emote.Equals(object)" />
 public override bool Equals(object other)
 => Emote.Equals(other);
Пример #7
0
 /// <summary>
 /// Constructs a new <see cref="EmoteAbstraction"/> around an existing <see cref="Discord.Emote"/>.
 /// </summary>
 /// <param name="emote">The existing <see cref="Discord.Emote"/> to be abstracted.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="emote"/>.</exception>
 public EmoteAbstraction(Emote emote)
 {
     Emote = emote ?? throw new ArgumentNullException(nameof(emote));
 }
Пример #8
0
 public void Test_Invalid_Amimated_Emote_Parse()
 {
     Assert.False(Emote.TryParse("<x:typingstatus:394207658351263745>", out _));
     Assert.False(Emote.TryParse("<a:typingstatus>", out _));
     Assert.False(Emote.TryParse("<a:typingstatus:not_a_number>", out _));
 }
Пример #9
0
 public void Test_Invalid_Emote_Parse()
 {
     Assert.False(Emote.TryParse("invalid", out _));
     Assert.False(Emote.TryParse("<:typingstatus:not_a_number>", out _));
     Assert.Throws <ArgumentException>(() => Emote.Parse("invalid"));
 }
Пример #10
0
        public async Task Help([Remainder] string args = null)
        {
            Uno_Score_Tracking.GuildCache.IncrementCMD();
            if (args != null)
            {
                switch (args)
                {
                case "uno": await ReplyAsync("", false, unogen); break;

                case "pets": await ReplyAsync("", false, unoadmin); break;

                case "admin": break;

                case "bot":
                case "general": await ReplyAsync("", false, bot);  break;

                case "reactions": await ReplyAsync("", false, reaccs); break;
                }
            }
            var msg = await Context.Channel.SendMessageAsync("**Please choose a Help category:**\n" +
                                                             "\n<:unoblue:530193416634630164> *Uno Server* <:unoblue:530193416634630164>" +
                                                             "\n<:unoblack:530193428919877653> *Uno Admin* <:unoblack:530193428919877653>" +
                                                             "\n<:uuwuu:580852963371646996> *Reactions* <:uuwuu:580852963371646996>" +
                                                             "\n:hatching_chick: *Pets* :hatching_chick:" +
                                                             "\n:gear: *General Bot* :gear:");

            Emote.TryParse("<:unoblue:530193416634630164>", out var blueUno);
            Emote.TryParse("<:unoblack:530193428919877653>", out var blackUno);
            Emote.TryParse("<:uuwuu:580852963371646996>", out var uwu);
            Emote.TryParse("<:chick:580865421469548554>", out var chick);
            Emote.TryParse("<:legear:580865450850779154>", out var gear);
            Server.Channel.AddReactions(msg, new List <Emote> {
                blueUno, blackUno, uwu, chick, gear
            });
            Discord.Emote reaccType = null;
            for (int i = 0; i < 150; i++)
            {
                var reaction = Server.Channel.GetFirstReaction(msg, new List <Emote> {
                    blueUno,
                    blackUno, uwu, chick, gear
                }, Context.User.Id);
                if (reaction != null)
                {
                    reaccType = reaction.Item2;
                    break;
                }
                Thread.Sleep(100);
                i++;
            }
            if (reaccType == null)
            {
                await ReplyAsync("The help request has timed out."); return;
            }
            switch (reaccType.Name)
            {
            case "unoblue":
                await ReplyAsync("", false, unogen);

                break;

            case "unoblack":
                await ReplyAsync("", false, unoadmin);

                break;

            case "uuwuu":
                await ReplyAsync("", false, reaccs);

                break;

            case "chick":
                await ReplyAsync("Not yet available.");

                break;

            case "legear":
                await ReplyAsync("", false, bot);

                break;
            }

            return;
        }
Пример #11
0
        public async Task Help([Remainder] string args = null)
        {
            Uno_Score_Tracking.GuildCache.IncrementCMD();
            if (args != null)
            {
                switch (args)
                {
                case "uno": await ReplyAsync("", false, unogen); break;

                case "admin": break;

                case "bot":
                case "general": await ReplyAsync("", false, bot); break;

                case "reactions": await ReplyAsync("", false, reaccs); break;
                }
            }
            var msg = await Context.Channel.SendMessageAsync("**Please choose a Help category:**\n" +
                                                             "\n<:UnoRed:472812408986009600>  *Uno Server* <:UnoRed:472812408986009600> " +
                                                             "\n<:UnoADMIN:540770331426816001>  *Uno Admin* <:UnoADMIN:540770331426816001> " +
                                                             "\n<:uuwuu:580852963371646996> *Reactions* <:uuwuu:580852963371646996>" +
                                                             "\n:gear: *General Bot* :gear:");

            Emote.TryParse("<:UnoRed:472812408986009600>", out var blueUno);
            Emote.TryParse("<:UnoADMIN:540770331426816001>", out var blackUno);
            Emote.TryParse("<:uuwuu:580852963371646996>", out var uwu);
            Emote.TryParse("<:legear:580865450850779154>", out var gear);
            Server.Channel.AddReactions(msg, new List <Emote> {
                blueUno, blackUno, uwu, gear
            });
            Discord.Emote reaccType = null;
            for (int i = 0; i < 150; i++)
            {
                var reaction = Server.Channel.GetFirstReaction(msg, new List <Emote> {
                    blueUno,
                    blackUno, uwu, gear
                }, Context.User.Id);
                if (reaction != null)
                {
                    reaccType = reaction.Item2;
                    break;
                }
                Thread.Sleep(100);
                i++;
            }
            if (reaccType == null)
            {
                await ReplyAsync("The help request has timed out."); return;
            }
            switch (reaccType.Name.ToLower())
            {
            case "unored":
                await ReplyAsync("", false, unogen);

                break;

            case "unoadmin":
                await ReplyAsync("", false, unoadmin);

                break;

            case "uuwuu":
                await ReplyAsync("", false, reaccs);

                break;

            case "legear":
                await ReplyAsync("", false, bot);

                break;
            }

            return;
        }
Пример #12
0
 public static Discord.Emote GetEmojiFromRank(string rank)
 {
     Discord.Emote emote = Emote.Parse("<" + RankingEmotes[rank] + ">");
     return(emote);
 }