Exemple #1
0
        public async Task RaritiesMessage()
        {
            string message;
            var    emotes = MarketHelper.GetRarities(Context.Bot, 0);

            foreach (var rarity in Rarity.Rarities)
            {
                message = $"```\n{rarity.Label}:\n";
                foreach (var e in emotes[rarity])
                {
                    message += new Discord.Emoji(e);
                }
                message += "\n```";
                await ReplyAsync(message);
            }
        }
Exemple #2
0
        /// <summary>
        ///     Determines whether the specified emoji is equal to the current one.
        /// </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);
            }

            Emoji otherEmoji = other as Emoji;

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

            return(string.Equals(Name, otherEmoji.Name));
        }
Exemple #3
0
        public static EphemeralEmoji FromRawData(string name, ulong?id = null, bool isAnimated = false)
        {
            var animatedPrefix = isAnimated
                ? "a"
                : string.Empty;

            var raw = $"<{animatedPrefix}:{name}:{id}>";

            if (Emote.TryParse(raw, out var emote))
            {
                return(new EphemeralEmoji()
                       .WithEmoteData(emote));
            }
            else
            {
                var emoji = new Discord.Emoji(name);

                return(new EphemeralEmoji()
                       .WithEmojiData(emoji));
            }
        }
Exemple #4
0
        internal static string ResolveEmoji(ITag tag, TagHandling mode)
        {
            if (mode != TagHandling.Remove)
            {
                Emoji emoji = (Emoji)tag.Value;
                switch (mode)
                {
                case TagHandling.Name:
                case TagHandling.FullName:
                    return($":{emoji.Name}:");

                case TagHandling.NameNoPrefix:
                case TagHandling.FullNameNoPrefix:
                    return($"{emoji.Name}");

                case TagHandling.Sanitize:
                    return($"<{emoji.Id}{SanitizeChar}:{SanitizeChar}{emoji.Name}>");
                }
            }
            return("");
        }
Exemple #5
0
        public static bool TryParse(string text, out Emoji result)
        {
            result = default(Emoji);
            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 Emoji(id, name);
                return(true);
            }
            return(false);
        }
Exemple #6
0
        public static async Task Handle(SocketUserMessage message)
        {
            if (message.Author.Id == 598740888562302977)
            {
                return;
            }
            ISocketMessageChannel channel = message.Channel;

            if (!(channel is SocketGuildChannel) || (channel as SocketGuildChannel).Guild.Id != 598338172958670858)
            {
                return;
            }

            var id = new int[9];

            for (var i = 0; i < 9; i++)
            {
                id[i] = random.Next(9);
            }

            var lastDigit = id[8];
            var rank      = 1;

            for (var i = 7; i >= 0; i--)
            {
                if (lastDigit != id[i])
                {
                    break;
                }
                rank++;
            }

            Emoji emoji = null;

            switch (rank)
            {
            case 3:
                emoji = new Emoji("3️⃣");
                break;

            case 4:
                emoji = new Emoji("4️⃣");
                break;

            case 5:
                emoji = new Emoji("5️⃣");
                break;

            case 6:
                emoji = new Emoji("6️⃣");
                break;

            case 7:
                emoji = new Emoji("7️⃣");
                break;

            case 8:
                emoji = new Emoji("8️⃣");
                break;

            case 9:
                emoji = new Emoji("9️⃣");
                break;
            }

            if (emoji != null)
            {
                if (await Capitalism.AddDubsToken(message.Author.Id, rank))
                {
                    await message.AddReactionAsync(emoji);
                }
            }
        }
        public static async Task PerformAsync(ISocketMessageChannel channel, Discord.IUserMessage message, Discord.Emoji candidate, DataBase db)
        {
            if (!(channel is SocketGuildChannel guildChannel))
            {
                return;
            }

            var guild = Guild.FindOrCreate.Perform(guildChannel.Guild, db);

            var author = message.Embeds.First().Author.Value;

            var description = message.Embeds.First().Fields.Last().Value;

            var id = Convert.ToInt32(description.Substring(description.IndexOf('#') + 1).Split("\n")[0]);

            var card = Helpers.FindById.Perform(id);

            var cards = Views.Card.GetAssociatedCards(card);

            var childCard = cards[Views.Card.Labels.IndexOf(candidate)];

            await Helpers.SendCards.PerformAsync(channel, new Models.Card[] { childCard.Item1 }, guild.DisplaySetting, guild.Language);
        }
Exemple #8
0
 public MessageReaction()
 {
     OnClientUpdated += (sender, e) => Emoji.SetClient(Client);
 }
Exemple #9
0
 public override string ToString()
 {
     return(Emoji.ToString());
 }
Exemple #10
0
 public EphemeralEmoji WithEmojiData(Discord.Emoji emoji)
 {
     _emoji = emoji;
     return(this);
 }
Exemple #11
0
 public MessageReactionAddEventArgs(Message message, Emoji emoji)
 {
     Emoji = emoji;
 }