Answer the question
In order to leave comments, you need to log in
How to declare a guild for a bot yourself?
There is one bot code. It is necessary that it checks for the presence of the user on the server. I tried to announce the server through its id, but it didn't work... You won't be able to receive it through the message, because the message is in the bot's personal.
Here is the code itself, but I don't think it can help in this matter:
//Объявление разной дичи
const Discord = require('discord.js');
const bot = new Discord.Client;
console.log('Анонимный чат готов к работе.')
const {
token,
webhokID,
webhookTK,
sishookTK,
sishokID} = require('./config.json');
const hook = new Discord.WebhookClient(webhokID, webhookTK);
const sisHook = new Discord.WebhookClient(sishokID, sishookTK);
//Системные сообщения
bot.on('ready', () =>{
sisHook.send('Бот полностью готов функционировать и приносить радость!')
});
bot.on('error', () =>{
sisHook.send("Что-то сломалось... почините меня...\n" + error)
});
//код
bot.on('message', message => {
if(message.author === bot.user) return;
if(message.content.startsWith('/') && message.channel.type == "dm") {
message.content = message.content.replace("/","")
hook.send(message.content);
console.log(message.author + " сказал " + '"' + message.content + '"')
}
});
//Ну, это понятно всем...
bot.login(token);
Answer the question
In order to leave comments, you need to log in
1. Collect the IDs of all server users in an array:
let arr = [];
message.guild.members.cache.forEach(u => arr.push(u.id))
.includes
, check the array for the presence of a specific user:if (arr.includes("id_пользователя") === true) {
...
} else {
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question