コード例 #1
0
        private async Task HandleCommand(SocketMessage arg)
        {
            var message = arg as SocketUserMessage;

            if (arg.Author.IsBot || message == null)
            {
                if (message.Channel.Id.Equals(424510923806343178))
                {
                    ulong.TryParse(message.Content, out ulong userid);
                    Modules.Currency currency = new Modules.Currency();
                    currency.Add(userid, 150, out int val);
                    IDMChannel x = await(_client.GetUser(userid)).GetOrCreateDMChannelAsync();
                    await x.SendMessageAsync($"`Thanks for voting!`\n`Shekels:` {val}{Modules.Currency.shekel}");

                    return;
                }
                return;
            }
            int argPos = 0;

            if (((message.Content.ToLower().Contains("discord.gg") || (message.Content.ToLower().Contains("discord.me"))) && !IsVip(message.Author)) && Convert.ToBoolean(_vMem._vMemory[(message.Channel as SocketGuildChannel).Guild.Id][Settings.DeleteInviteMSG]))
            {
                await message.DeleteAsync();

                await message.Channel.SendMessageAsync($"{message.Author.Mention} Please don't send invite links!");
            }
            else if (!Convert.ToInt32(_vMem._vMemory[(message.Channel as SocketGuildChannel).Guild.Id][Settings.CharSpam]).Equals(0) && HasConsecutiveChars(message.Content, Convert.ToInt32(Ext._vMem._vMemory[(message.Channel as SocketGuildChannel).Guild.Id][Settings.CharSpam])) && !IsVip(message.Author))
            {
                await message.DeleteAsync();

                await message.Channel.SendMessageAsync($"{message.Author.Mention} Don't type nonsense!");
            }

            /*
             * else if (HasConsecutiveWords(message.Content, Convert.ToInt32(jSon.Settings((message.Channel as SocketGuildChannel).Guild, Modules.BaseCommands.Settings.WordSpam))) && !Modules.BaseCommands.isVip(message.Author))
             * {
             *  await message.DeleteAsync();
             *  await message.Channel.SendMessageAsync($"{message.Author.Mention} Don't type nonsense!");
             * }
             * else if (HasConsecutiveEmojis(message.Content, Convert.ToInt32(jSon.Settings((message.Channel as SocketGuildChannel).Guild, Modules.BaseCommands.Settings.EmojiSpam))) && !Modules.BaseCommands.isVip(message.Author))
             * {
             *  await message.DeleteAsync();
             *  await message.Channel.SendMessageAsync($"{message.Author.Mention} Don't type nonsense!");
             * }*/
            else if (!(message.HasCharPrefix(Convert.ToChar(_vMem._vMemory[(message.Channel as SocketGuildChannel).Guild.Id][Settings.Prefix]), ref argPos) || message.HasMentionPrefix(_client.CurrentUser, ref argPos)))
            {
                return;
            }
            var context = new CommandContext(_client, message);
            var result  = await _commands.ExecuteAsync(context, argPos, _services);

            if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
            {
                await context.Channel.SendMessageAsync(result.ErrorReason);
            }
        }
コード例 #2
0
        private async Task _client_ReactionAdded(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            if (!reaction.UserId.Equals(_client.CurrentUser.Id) && (channel as IGuildChannel).GuildId.Equals(215601994507878402))
            {
                for (int x = 1; x < Enum.GetValues(typeof(Store)).Length + 1; x++)
                {
                    if (new Emoji($"{x}\u20e3").Name.Equals(reaction.Emote.Name))
                    {
                        Modules.Currency currency = new Modules.Currency();
                        int        amount         = currency.Amount(reaction.UserId);
                        IDMChannel y = await _client.GetUser(170695871510347778).GetOrCreateDMChannelAsync();

                        switch (x)
                        {
                        case 1:
                            if (amount >= (int)Enum.GetValues(typeof(Store)).GetValue(0))
                            {
                                currency.Subtract(reaction.UserId, (int)Enum.GetValues(typeof(Store)).GetValue(0), out int val0);
                                await y.SendMessageAsync($"{reaction.User.Value} - {Enum.GetValues(typeof(Store)).GetValue(0).ToString()}", false);
                            }
                            return;

                        case 2:
                            if (amount >= (int)Enum.GetValues(typeof(Store)).GetValue(1))
                            {
                                currency.Subtract(reaction.UserId, (int)Enum.GetValues(typeof(Store)).GetValue(1), out int val1);
                                await y.SendMessageAsync($"{reaction.User.Value} - {Enum.GetValues(typeof(Store)).GetValue(1).ToString()}", false);
                            }
                            return;

                        case 3:
                            if (amount >= (int)Enum.GetValues(typeof(Store)).GetValue(2))
                            {
                                currency.Subtract(reaction.UserId, (int)Enum.GetValues(typeof(Store)).GetValue(2), out int val2);
                                currency.Add_storage(reaction.UserId);
                                await channel.SendMessageAsync($"`{reaction.User.Value.Username} bought 5k slot expansion`");
                            }
                            return;

                        case 4:
                            if (amount >= (int)Enum.GetValues(typeof(Store)).GetValue(3))
                            {
                                currency.Subtract(reaction.UserId, (int)Enum.GetValues(typeof(Store)).GetValue(3), out int val3);
                                await y.SendMessageAsync($"{reaction.User.Value} - {Enum.GetValues(typeof(Store)).GetValue(3).ToString()}", false);
                            }
                            return;

                        case 5:
                            if (amount >= (int)Enum.GetValues(typeof(Store)).GetValue(4))
                            {
                                currency.Subtract(reaction.UserId, (int)Enum.GetValues(typeof(Store)).GetValue(4), out int val4);
                                await y.SendMessageAsync($"{reaction.User.Value} - {Enum.GetValues(typeof(Store)).GetValue(4).ToString()}", false);
                            }
                            return;

                        case 6:
                            if (amount >= (int)Enum.GetValues(typeof(Store)).GetValue(5))
                            {
                                currency.Subtract(reaction.UserId, (int)Enum.GetValues(typeof(Store)).GetValue(5), out int val5);
                                await y.SendMessageAsync($"{reaction.User.Value} - {Enum.GetValues(typeof(Store)).GetValue(5).ToString()}", false);
                            }
                            return;

                        case 7:
                            if (amount >= (int)Enum.GetValues(typeof(Store)).GetValue(6))
                            {
                                currency.Subtract(reaction.UserId, (int)Enum.GetValues(typeof(Store)).GetValue(6), out int val6);
                                await y.SendMessageAsync($"{reaction.User.Value} - {Enum.GetValues(typeof(Store)).GetValue(6).ToString()}", false);
                            }
                            return;

                        case 8:
                            if (amount >= (int)Enum.GetValues(typeof(Store)).GetValue(7))
                            {
                                currency.Subtract(reaction.UserId, (int)Enum.GetValues(typeof(Store)).GetValue(7), out int val6);
                                await y.SendMessageAsync($"{reaction.User.Value} - {Enum.GetValues(typeof(Store)).GetValue(7).ToString()}", false);
                            }
                            return;
                        }
                    }
                }
            }
        }