在其他文件上使用Discord的“消息”侦听器

时间:2020-08-08 11:56:09

标签: discord.js

我正在尝试在其他文件的函数中使用count=0 mail = input('enter email address: ') while True : for character in mail: if character == '@': count+=1 if count!=1: count=0 print('Invalid mail !! (error in \'@\')') mail = input('Enter valid mail: ') else : break 之类的命令。有没有没有message.delete();方法的添加侦听器的方法? I.E。

index.js

client.on()

我想像这样使用它

example.js

const Discord = require('discord.js');
const { prefix, token } = require('./config.json');
const client = new Discord.Client();

client.on('message', async message => {
//stuff here like message.delete(); or message.channel.send();
});

1 个答案:

答案 0 :(得分:0)

您可以使用处理程序导出变量。 https://discordjs.guide/command-handling/