blackninja
blackninja

Reputation: 11

Discord bot token resetting itself

I am getting follow message from discord and they keep resetting my bot token. Any assistance what could be wrong.

It appears your bot, TEST, has connected to Discord more than 1000 times within a short time period. Since this kind of behavior is usually a result of a bug we have gone ahead and reset your bot's token.

Upvotes: 0

Views: 2821

Answers (2)

53P
53P

Reputation: 16

From what I can see, every time the event is fired, it'll log into your bot again. Discord recognizes this and then resets your token. I would recommend removing

client.login('Client token xxxx') //

and putting it out of any events. You should also remove

client.login(token)

Upvotes: 0

Ghonima
Ghonima

Reputation: 3092

In your on message event

client.on('message', async msg => {
    msg.content = filter(msg.content)

    let channelid1 = 'xxxx' //
    let channelid2 = 'xx' //

    if (msg.channel.id == channelid1 && msg.author.id != client.user.id) {
        let attach = msg.attachments.array()
        let test = getUrls(msg.content);
        let arr = Array.from(test);
        let emojiname = ''

        if (msg.content.startsWith("<:uparrow:")) {
            emojiname = 'uparrow'
        } else if (msg.content.startsWith("<:downarrow:")) {
            emojiname = 'downarrow'
        }

        let name = msg.guild.emojis.find(emoji => emoji.name == emojiname);
        let embed = new Discord.RichEmbed()
            .setDescription(msg.content)
            .setColor('#A9A9A9')

        if (name) {
            start("Bot token xxxxx", 'Landing Discord channel ID xxx', embed, name)
        } else {
            start("Bot token xxxxx", 'Landing Discord channel ID xxx', embed)
        }

        if(arr.length > 0){
        for(let i in arr){
         start("Bot token xxxxx", 'Landing Discord channel ID xxx', arr[i])
         }
        }

        if (attach.length > 0) {
            start("Bot token xxxxx", 'Landing Discord channel ID xxx', attach[0].url)
        }
client.login('Client token xxxx') //
}

You need to remove calling the login function

client.login('Client token xxxx')

as you don't want your bot re-logging in every time the event is fired.

Upvotes: 1

Related Questions