#Using My own User Token

1 messages · Page 1 of 1 (latest)

dim light

I'm trying to make my own user copy and paste a message generated by a bot in my own server.
With API I'm able to send the message via this bot, all good. But then I'm running a script that should copy and paste the message with my own user. I understood by the guidelines that I could do this if I intend to not spam, and just use it for my own sake.

When I try to run the script it is telling me that my Token is invalid. I got my Token using discord on Chrome, then in the developer tools, library, authorization, and saved it in a config file.
Any ideas what is the problem? Am I getting the right token?

My code goes like this:

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
const config = require('./config.json');
const tnonToken = config.tnonToken;
const botName = config.botName;
const sourceChannelId = config.generalChannelId;

client.once('ready', () =>
{
console.log(Bot is ready! as: ${client.user.tag});
});

client.on('messageCreate', async message =>
{
if (message.author.bot)
{
if (!message.author.bot || message.channel.id !== sourceChannelId) // If the message is not from the source channel or a bot, ignore it
{
return;

    }
    if (message.author.username === botName) // Check if the message is from the bot with the specified name
    {
        await message.channel.send(`${message.content}`); // Send a new message in the same channel with the /imagine command and the original message's content
        console.log(`Received message: "${message.content}" from channel: "${message.channel.id}"`);
    }
}

});

client.login(tnonToken);