Answer the question
In order to leave comments, you need to log in
I work with the DiscordJS library, I need to make the bot send messages without an event, how to do it?
I am making a discord bot and I really need to make it so that the bot just takes and sends messages (for example, when some time passes or sending a message will be in another function), you need to bypass event tracking, here is an example code
async function sender(bot, message, args) {
if (brandshopp.type == '1') {
let embed = new Discord.MessageEmbed().setTitle(brandshopp.model)
.addField('**Тип релиза:**', '**Анонс**')
.addField('**Бренд**', brandshopp.name)
.setThumbnail(brandshopp.photo)
.addField('**Модель**', brandshopp.model)
.addField('**Useful Links**', '[Новинки](https://brandshop.ru/new/) | [Login](https://brandshop.ru/login/) | [Checkout ](https://brandshop.ru/checkout/)')
.setFooter(`${ brandshopp.time } куро`)
.setColor(0x32d160)
await message.channels.cache.get("тут айди канала").send(embed)
// bot.on('ready', () => {
// bot.channels.cache.get("тут айди канала").send(embed)
// })
}
}
sender(bot)
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'channel' of undefined
Answer the question
In order to leave comments, you need to log in
Send a message anywhere in the program:
var server = "server_id"
var channel = "channel_id"
client.guilds.get(server).channels.get(channel).send("text");
All discord.js is command based. Therefore, this makes no sense. Of course, you can track the text in the console, but this will not be a discord bot at all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question