Can't sent direct message

I wrote a slash command like this (you should get a DM to yourself when you run the command)
{
data: new SlashCommandBuilder()
.setName('dmtest')
.setDescription('sent direct message'),
async execute(interaction) {
client.users
.fetch('626680496834871308')
.then((user) => {
user.send(`Hello`,);
});
},
{
data: new SlashCommandBuilder()
.setName('dmtest')
.setDescription('sent direct message'),
async execute(interaction) {
client.users
.fetch('626680496834871308')
.then((user) => {
user.send(`Hello`,);
});
},
However, the following error occurs.
throw new Error("Expected token to be set for this request, but none was present");
^

Error: Expected token to be set for this request, but none was present
throw new Error("Expected token to be set for this request, but none was present");
^

Error: Expected token to be set for this request, but none was present
3 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
MrMythical
MrMythical2y ago
You are making a request when the token is not set If using client, client is unready it seems you are using client, instead of interaction.client, so you probably just created a new client instance
kokastar
kokastar2y ago
Oops, I forgot to make it an interaction.client. Resolved, thank you.