I made a discord bot, just tapping run does nothing at all

here’s my script, I downloaded discord.js too but no luck:

const Discord = require('discord.js');
const client = new Discord.Client();

const TOKEN = 'REMOVED INTENTIONALLY';

client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});

// Kick command
client.on('message', message => {
if (message.content.startsWith('!kick')) {
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.kick()
.then(() => {
message.reply(`Successfully kicked ${user.tag}`);
})
.catch(err => {
message.reply('Failed to kick member');
console.error(err);
});
} else {
message.reply("That user isn't in this guild!");
}
} else {
message.reply("You didn't mention the user to kick!");
}
}
});

// Mute command

client.on('message', message => {
if (message.content.startsWith('!mute')) {
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member.roles.add('1053979426091712522').then(() => {
message.reply(`Successfully muted ${user.tag}`);
}).catch(err => {
message.reply('Failed to mute member');
console.error(err);
});
} else {
message.reply("That user isn't in this guild!");
}
} else {
message.reply("You didn't mention the user to mute!");
}
}
});

// Ban command

client.on('message', message => {
if (message.content.startsWith('!ban')) {
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.ban()
.then(() => {
message.reply(`Successfully banned ${user.tag}`);
})
.catch(err => {
message.reply('Failed to ban member');
console.error(err);
});
} else {
message.reply("That user isn't in this guild!");
}
} else {
message.reply("You didn't mention the user to ban!");
}
}
});

client.login(TOKEN);

I could be wrong, but shouldn’t there be a client.run line?

ill be honest with u, idk…

still, i copied this script, it was made a few weeks ago and comments say it works, also I tried other scripts too!

Actually I’m not sure on that, haven’t seen one of these run in node before, lemme look over the code again.

deeply appreciate your assistance.

Two requests:

  1. Put your token in the Secrets tab of your repl (I’m pretty sure Node has Secrets?)
  2. If you were able to put the token in Secrets, tell your code to read the env variable that contains it, instead if it being hardcoded in
  3. If you were able to do the above, please share a repl link
1 Like

secrets? .env? arent those removed? however if u check line 4 i intentionally removed the token, as even with it, does not work

you could add my discord, Noona#8529, and check the code personally.

.env is removed, yes. Secrets is essentially replit’s version of it (I believe it is encrypted too)

i forgot the period after “Noona”:
Noona.#8529

I would, but I am basically never on discord, and how would being on discord allow me to check the code?

yes, but instructions for the script doesn’t include me adding secrets!
but what shocked me is that it worked for everyone else.

send you the replit link

How long ago did it work for everyone else? IIRC discord changed things recently, and broke older tutorials, and no new ones have come out yet.

5 days ago was a comment from someone, “thanks! works perfectly”

You could PM it to me through Ask. (this forum)

Hmm. That’s interesting then.

sorry, im new here and don’t know how.

Just click on my profile picture and select “Message” (Actually I don’t remember if TL0 or TL1 can PM…)