I’ve configured all my bot details as PRESENCE INTENT, SERVER MEMBERS INTENT, MESSAGE CONTENT INTENT. I also invited my bot to my channel so it can be found. For those who would like to use it. And all the code I think looks well. What’s wrong with it then?
Here is my code
const axios = require("axios");
const { Client, GatewayIntentBits } = require("discord.js");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages,
],
});
client.on("ready", () => {
console.log(`Zalogowano jako ${client.user.tag}!`);
});
client.on("messageCreate", async (message) => {
if (message.content.startsWith("!verify")) {
const userId = message.content.split(" ")[1];
if (!userId) return message.reply("Proszę podać ID użytkownika.");
const userExists = await verifyUser(userId);
if (userExists) {
const channel = client.channels.cache.get("1226659763505598516");
if (channel) {
channel.permissionOverwrites
.create(message.author.id, { ViewChannel: true })
.then(() => message.reply("Dodano Cię do kanału."))
.catch(console.error);
}
} else {
message.reply("Niepoprawny numer konta.");
}
} else {
message.reply("Hej! Wykonaj komendę !verify TWÓJ_NUMER_KONTA aby Cię zweryfikować.")
}
});
const verifyUser = async (userId) => {
try {
const response = await axios.post(
"https://geografiana100.pl/discord/check-user.php",
{
userId: userId,
}
);
if (response.data && response.data.exists === true) {
return true;
} else {
return false;
}
} catch (error) {
console.error("Błąd przy weryfikacji użytkownika:", error);
return false;
}
};
client.login(
"MY_TOKEN"
);