Как решить эту проблему с отсутствием тени, но при этом добиться того же эффекта? - PullRequest
0 голосов
/ 07 августа 2020

Это фрагмент кода, который у меня есть.

    name: 'inventory',
    description: 'Shows the inventory.',
    execute(message, args) {
        const Discord = require('discord.js');
        const client = new Discord.Client();
        client.on('message', async message => {
            const { Users, CurrencyShop } = require('./dbObjects');
            const { Op } = require('sequelize');
            const currency = new Discord.Collection();
            const PREFIX = 'k!';

            if (message.author.bot) return;

            if (!message.content.startsWith(PREFIX)) return;
            const input = message.content.slice(PREFIX.length).trim();
            if (!input.length) return;
            const [, command, commandArgs] = input.match(/(\w+)\s*([\s\S]*)/);
            const target = message.mentions.users.first() || message.author;
            const user = await Users.findOne({ where: { user_id: target.id } });
            const items = await user.getItems();

            if (!items.length) return message.channel.send(`${target.tag} has nothing!`);
            return message.channel.send(`${target.tag} currently has ${items.map(i => `${i.amount} ${i.item.name}`).join(', ')}`);
        });
    } };

VS C говорит, что 'message' уже объявлено в верхней области. Я использую Discord. js для кодирования этого бота Discord. Если я удалю «сообщение» в execute(message, args), мой код не сработает. Могли бы быть какие-нибудь советы, как это исправить? Любая помощь будет принята с благодарностью.

...