简体   繁体   中英

Can I print the console log of my discord bot into a specific channel in discord.js?

I am making a discord bot which will send a dm to a particular user if the staff types ",ping<@mentionusername>" so. i want my bot to record its console logs of node.js in a particular channel so that other staff members can also see the logs instead of just the developer? Can anyone share with me the code for it?

Maybe you can create your own log function, or hooking the console.log function.

Simple way:

function log(msg) 
{
    console.log(msg);
    const channel = member.guild.channels.cache.find(ch => ch.name === 'log');
    if (!channel) return;
    channel.send(msg);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM