DIA
discord.js - Imagine an app! Tennessine [busy a few days]

can someon help me with a bot discord (discord.js node)

I created a discord bot in node, and for the ",ping" command it sends the same message 3 times... can it be solved? I can send the src, I have no problem with that!
DT
d.js toolkit44d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
TBA
! Tennessine [busy a few days]44d ago
discord.js@12.5.3 and v20.10.0
M
mallusrgreat44d ago
update djs
TBA
! Tennessine [busy a few days]44d ago
ok
TBA
! Tennessine [busy a few days]44d ago
i have this problem
No description
TBA
! Tennessine [busy a few days]44d ago
i need to ping one time and to contorize the pings.. in a few moments... Well, can't you help me with the code? I can not handle it i can update discord.js@13.0.0-dev.5af2ef5fbc7ad11281f38384c360ae79efe63b39 done
TBA
! Tennessine [busy a few days]44d ago
No description
TBA
! Tennessine [busy a few days]44d ago
ok, latest done
TBA
! Tennessine [busy a few days]44d ago
No description
DD
d.js docs44d ago
:guide: Additional Information: Updating from v12 to v13 read more :guide: Additional Information: Updating from v13 to v14 read more
TBA
! Tennessine [busy a few days]41d ago
require("dotenv").config();
const { Client, Collection, Intents } = require("discord.js");
const fs = require("fs");
const path = require("path");

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const prefix = ",";

const token = process.env.TOKEN;

if (!token || typeof token !== "string") {
throw new Error("TOKEN_INVALID: Tokenul furnizat este invalid.");
}

const pingCount = new Map();

const commandFiles = fs
.readdirSync(path.resolve("./src"))
.filter((file) => file.endsWith(".js"));

const commands = new Collection();
for (const file of commandFiles) {
try {
const command = require(path.resolve(`./src/${file}`));
commands.set(command.name, command);
} catch (error) {
console.error(`Eroare încărcare comandă: ${file}`, error);
}
}

client.once("ready", () => {
console.log("Botul este online!");
});

client.on("messageCreate", async (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) {
if (message.channel.name.startsWith("slot-")) {
if (message.mentions.users.size > 0) {
const user = message.author;
let count = pingCount.get(user.id) || 0;
count++;

if (count > 1) {
message.channel.send(
`${user}, nu poți trimite ping-uri repetate! Canalul va fi șters.`
);
message.channel.delete();
return;
}

message.channel.send(`${user}, ${count}/1 ping-uri permise.`);

pingCount.set(user.id, count);
}
}
return;
}

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();

if (commands.has(commandName)) {
const command = commands.get(commandName);

if (
command.requiresAdmin &&
!message.member.permissions.has("ADMINISTRATOR")
) {
message.reply("Doar administratorii pot folosi această comandă.");
return;
}

try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply("A apărut o eroare în timpul execuției comenzii.");
}
}

if (message.content.startsWith(prefix + "ping")) {
if (!pingCount.has(message.author.id)) {
pingCount.set(message.author.id, 0);
}

let count = pingCount.get(message.author.id);
count++;

if (count > 1) {
message.channel.send(
`${message.author}, Ai folosit toate ping-urile posibile pentru astăzi. Cooldown de 24 de ore.`
);
message.channel.send(
`Nu puteți mai trimite ping-uri în acest canal pentru 24 de ore.`
);

message.channel.permissionOverwrites.edit(message.guild.roles.everyone, {
SEND_MESSAGES: false,
});

setTimeout(() => {
message.channel.permissionOverwrites.edit(message.guild.roles.everyone, {
SEND_MESSAGES: null,
});
}, 24 * 60 * 60 * 1000);

message.channel.send(
`ANNO! 🚨 Te rog să nu mai dai ping persoanelor. Vei pierde accesul slot-ului!`
);

return;
}

message.channel.send(`<@&1148177424647999529>`);
message.channel.send(`${count}/2 ping-uri folosite.`);
pingCount.set(count);
}
});

client.login(token);
require("dotenv").config();
const { Client, Collection, Intents } = require("discord.js");
const fs = require("fs");
const path = require("path");

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const prefix = ",";

const token = process.env.TOKEN;

if (!token || typeof token !== "string") {
throw new Error("TOKEN_INVALID: Tokenul furnizat este invalid.");
}

const pingCount = new Map();

const commandFiles = fs
.readdirSync(path.resolve("./src"))
.filter((file) => file.endsWith(".js"));

const commands = new Collection();
for (const file of commandFiles) {
try {
const command = require(path.resolve(`./src/${file}`));
commands.set(command.name, command);
} catch (error) {
console.error(`Eroare încărcare comandă: ${file}`, error);
}
}

client.once("ready", () => {
console.log("Botul este online!");
});

client.on("messageCreate", async (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) {
if (message.channel.name.startsWith("slot-")) {
if (message.mentions.users.size > 0) {
const user = message.author;
let count = pingCount.get(user.id) || 0;
count++;

if (count > 1) {
message.channel.send(
`${user}, nu poți trimite ping-uri repetate! Canalul va fi șters.`
);
message.channel.delete();
return;
}

message.channel.send(`${user}, ${count}/1 ping-uri permise.`);

pingCount.set(user.id, count);
}
}
return;
}

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();

if (commands.has(commandName)) {
const command = commands.get(commandName);

if (
command.requiresAdmin &&
!message.member.permissions.has("ADMINISTRATOR")
) {
message.reply("Doar administratorii pot folosi această comandă.");
return;
}

try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply("A apărut o eroare în timpul execuției comenzii.");
}
}

if (message.content.startsWith(prefix + "ping")) {
if (!pingCount.has(message.author.id)) {
pingCount.set(message.author.id, 0);
}

let count = pingCount.get(message.author.id);
count++;

if (count > 1) {
message.channel.send(
`${message.author}, Ai folosit toate ping-urile posibile pentru astăzi. Cooldown de 24 de ore.`
);
message.channel.send(
`Nu puteți mai trimite ping-uri în acest canal pentru 24 de ore.`
);

message.channel.permissionOverwrites.edit(message.guild.roles.everyone, {
SEND_MESSAGES: false,
});

setTimeout(() => {
message.channel.permissionOverwrites.edit(message.guild.roles.everyone, {
SEND_MESSAGES: null,
});
}, 24 * 60 * 60 * 1000);

message.channel.send(
`ANNO! 🚨 Te rog să nu mai dai ping persoanelor. Vei pierde accesul slot-ului!`
);

return;
}

message.channel.send(`<@&1148177424647999529>`);
message.channel.send(`${count}/2 ping-uri folosite.`);
pingCount.set(count);
}
});

client.login(token);
this is src and this is the problem and what can i do? done install We need to take into account the v13 changes in the updateOverwrite method. In v13, the updateOverwrite method was replaced by permissionOverwrites.edit.
require("dotenv").config();
const { Client, Collection, Intents } = require("discord.js");
const fs = require("fs");
const path = require("path");

const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});
const prefix = ",";

const token = process.env.TOKEN;

if (!token || typeof token !== "string") {
throw new Error("TOKEN_INVALID: Tokenul furnizat este invalid.");
}

const pingCount = new Map();

const commandFiles = fs
.readdirSync(path.resolve("./src"))
.filter((file) => file.endsWith(".js"));

const commands = new Collection();
for (const file of commandFiles) {
try {
const command = require(path.resolve(`./src/${file}`));
commands.set(command.name, command);
} catch (error) {
console.error(`Eroare încărcare comandă: ${file}`, error);
}
}

client.once("ready", () => {
console.log("Botul este online!");
});

client.on("messageCreate", async (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) {
if (message.channel.name.startsWith("slot-")) {
if (message.mentions.users.size > 0) {
const user = message.author;
let count = pingCount.get(user.id) || 0;
count++;

if (count > 1) {
message.channel.send(
`${user}, nu poți trimite ping-uri repetate! Canalul va fi șters.`
);
message.channel.delete();
return;
}

message.channel.send(`${user}, ${count}/1 ping-uri permise.`);

pingCount.set(user.id, count);
}
}
return;
}

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();

if (commandName === "ping") {
if (!pingCount.has(message.author.id)) {
pingCount.set(message.author.id, 0);
}

let count = pingCount.get(message.author.id);
count++;

if (count > 2) {
message.channel.send(
`${message.author}, Ai folosit toate ping-urile posibile pentru astăzi. Cooldown de 24 de ore.`
);
message.channel.send(
`Nu puteți mai trimite ping-uri în acest canal pentru 24 de ore.`
);

message.channel.permissionOverwrites.edit(message.guild.roles.everyone, {
SEND_MESSAGES: false,
});

setTimeout(() => {
message.channel.permissionOverwrites.edit(
message.guild.roles.everyone,
{
SEND_MESSAGES: true,
}
);
}, 24 * 60 * 60 * 1000);

message.channel.send(
`ANNO! 🚨 Te rog să nu mai dai ping persoanelor. Vei pierde accesul slot-ului!`
);

return;
}

message.channel.send(`<@&1148177424647999529>`);
message.channel.send(`${count}/2 ping-uri folosite.`);
pingCount.set(message.author.id, count);
} else {
const command = commands.get(commandName);
if (!command) return;
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply("A apărut o eroare în timpul execuției comenzii.");
}
}
});

client.login(token);
require("dotenv").config();
const { Client, Collection, Intents } = require("discord.js");
const fs = require("fs");
const path = require("path");

const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});
const prefix = ",";

const token = process.env.TOKEN;

if (!token || typeof token !== "string") {
throw new Error("TOKEN_INVALID: Tokenul furnizat este invalid.");
}

const pingCount = new Map();

const commandFiles = fs
.readdirSync(path.resolve("./src"))
.filter((file) => file.endsWith(".js"));

const commands = new Collection();
for (const file of commandFiles) {
try {
const command = require(path.resolve(`./src/${file}`));
commands.set(command.name, command);
} catch (error) {
console.error(`Eroare încărcare comandă: ${file}`, error);
}
}

client.once("ready", () => {
console.log("Botul este online!");
});

client.on("messageCreate", async (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) {
if (message.channel.name.startsWith("slot-")) {
if (message.mentions.users.size > 0) {
const user = message.author;
let count = pingCount.get(user.id) || 0;
count++;

if (count > 1) {
message.channel.send(
`${user}, nu poți trimite ping-uri repetate! Canalul va fi șters.`
);
message.channel.delete();
return;
}

message.channel.send(`${user}, ${count}/1 ping-uri permise.`);

pingCount.set(user.id, count);
}
}
return;
}

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();

if (commandName === "ping") {
if (!pingCount.has(message.author.id)) {
pingCount.set(message.author.id, 0);
}

let count = pingCount.get(message.author.id);
count++;

if (count > 2) {
message.channel.send(
`${message.author}, Ai folosit toate ping-urile posibile pentru astăzi. Cooldown de 24 de ore.`
);
message.channel.send(
`Nu puteți mai trimite ping-uri în acest canal pentru 24 de ore.`
);

message.channel.permissionOverwrites.edit(message.guild.roles.everyone, {
SEND_MESSAGES: false,
});

setTimeout(() => {
message.channel.permissionOverwrites.edit(
message.guild.roles.everyone,
{
SEND_MESSAGES: true,
}
);
}, 24 * 60 * 60 * 1000);

message.channel.send(
`ANNO! 🚨 Te rog să nu mai dai ping persoanelor. Vei pierde accesul slot-ului!`
);

return;
}

message.channel.send(`<@&1148177424647999529>`);
message.channel.send(`${count}/2 ping-uri folosite.`);
pingCount.set(message.author.id, count);
} else {
const command = commands.get(commandName);
if (!command) return;
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply("A apărut o eroare în timpul execuției comenzii.");
}
}
});

client.login(token);
it s ok now? I updated the code, but I see that a problem has been solved. but i have two now... the first problem is that it does not count pings. This means that 1/2 of the used pings are also written the second time. The second problem is that the ",list" command no longer works, which used to work before. Immediately you also receive "list.js"
const { Client, Intents } = require("discord.js");
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});

const prefix = ",";

client.on("messageCreate", (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();

if (command === "list") {
if (args.length < 2) {
return message.reply("Folosește comanda astfel: ,list <ID> <motiv>");
}

const userID = args[0];
const member = message.guild.members.cache.get(userID);
const username = member ? member.displayName : "Utilizator necunoscut";
const reason = args.slice(1).join(" ");

const messageContent = `${username} - ID: ${userID} - ${reason}`;

const channel = client.channels.cache.get("953052947879702621");
if (channel) {
channel.send(messageContent);
} else {
console.error("Canalul nu a fost găsit!");
}
}
});

client.login(process.env.TOKEN);
const { Client, Intents } = require("discord.js");
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});

const prefix = ",";

client.on("messageCreate", (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();

if (command === "list") {
if (args.length < 2) {
return message.reply("Folosește comanda astfel: ,list <ID> <motiv>");
}

const userID = args[0];
const member = message.guild.members.cache.get(userID);
const username = member ? member.displayName : "Utilizator necunoscut";
const reason = args.slice(1).join(" ");

const messageContent = `${username} - ID: ${userID} - ${reason}`;

const channel = client.channels.cache.get("953052947879702621");
if (channel) {
channel.send(messageContent);
} else {
console.error("Canalul nu a fost găsit!");
}
}
});

client.login(process.env.TOKEN);
this is list.js Ok..
Want results from more Discord servers?
Add your server
More Posts
I'm trying to make my Discord Bot Reply when a user sends an Image in ChatI have a working discord bot that responds to people and I'm even getting it to tell me the weather Can you use variable in embedBuilder name and description?I have a embedBuilder instance and It doesn't seem to work. const embed = new EmbedBuilder() Bot stopped workingmy bot suddenly stopped working, it says 'application did not respond' when i try to run any commandHow to get the user id, username, nick when mentioned by another userI tried `m.mentions.members.first()` but to no avail it didn't work as expected due to the `mentionsShifts logsHello, I've been thinking of adding a command to my bot that logs people's shifts. The concept is tDiscordAPIError[10008]: Unknown Message} /root/bots/Synth/node_modules/@discordjs/rest/dist/index.js:640 throw new DiscordAPIError(daim still new to all this and cant install node.js to discord and need some help if possibleim sorry for asking this but all videos are so confusing and dont show all the stepsmember.setNickname or member.roles.add occasionally not workingHi all, What reasons are there for a nickname potentially not being applied, or a role potentially I have an error in my botHello, sorry for the inconvenience, but I have a problem with my bot, since it turns off due to an eButton QuestionHow can i make a button never expire?Commands not refreshing after being correctly deployedGood evening. I'm developing a discord.js bot using typescript. I am having trouble using my deployeguild.guildScheduledEventUserAdd event failing to fire consistentlyI am having an issue with the guildScheduledEventUserAdd event. It seems to trigger sometimes but whWhere do I start from?Hi, Can y'all share some helpful resouces with me so that I can understand and learn about npmjs?? THelp me plsCode: Error: `[WARNING] The command at C:\Users\OE104655\Videos\Eendsmp bot\commands\utility\giveawHelp me plsIdk whats wrong with this line of code: `const client = new Client({ intents: [GatewayIntentBits.Guiis it possible to run command 1 from command 2so like command 1 is /embed title: description: And i want to run that command with pre-set values fHow do I add a role with discord.js```js const target = interaction.options.getUser('target'); const role = interaction.options.getRolecheck if role is set to certain role idshow do i check if the role is set to certain ids? ```js const role = interaction.optHow do you turn on a discord bot?It ain't onErrorroot@VPS-10384:~/7bLogsBot# node index node:internal/modules/cjs/loader:1137 throw err; ^ Error