N
N
Nikita NeVajno2020-12-30 01:57:53
JavaScript
Nikita NeVajno, 2020-12-30 01:57:53

TypeError: Cannot read property 'set' of null?

Hello.
All with the upcoming.
I'm trying to make a bot for Discord. Namely, right now, the welcome command, which should be responsible for greeting new users on the server. That is, a person enters the server and writes "Welcome ....." to him. The problem is that you need to do it in such a way that the text can be changed.
Here is the error code:

spoiler
const { Command } = require('discord.js-commando');
const Jimp = require("jimp");

module.exports = class WelcomeCommand extends Command{
    constructor(client){
        super(client, {
            name : 'welcome',
            group : 'guild',
            memberName : 'welcome',
            description : 'Приветствие',
            guildOnly: true,
            userPermissions: ['MANAGE_GUILD'],
            throttling : {
                usages : 1,
                duration : 5
            },
            args:
            [
                {
                    key:'channel',
                    prompt : 'В каком канале будут выполняться приветствия?',
                    type : 'channel',
                    wait : 60
                },
                {
                    key:'text',
                    prompt : 'Какое сообщение?\n' +
                    "Используйте ${USER} чтобы упомянуть нового пользователя, ${GUILD} чтобы упомянуть название сервера,${TAG} чтобы узнать имя #tag,  и ${COUNT} чтобы узнать количество пользователей",
                    type : 'string',
                    wait : 240
                }
            ]
        });
    }
    run(message, {channel, text}){
        
        this.client.provider.set(message.guild.id, "welcome_channel" , channel.id);
        this.client.provider.set(message.guild.id, "welcome_message", text);
        message.channel.send(`Сообщение с приветствием установлено в канал ${channel}. Используйте команду ${this.client.commandPrefix},чтобы добавить изображение \n`+
        `Вы можете протестировать приветствие командой: ${this.client.commandPrefix}`);
    }
}

Gives an error message :
spoiler
TypeError: Cannot read property 'set' of null

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2020-12-30
@HistoryART

You are applying .set to void, try replacing .this with .channel (I'm thinking logically)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question