【发布时间】:2021-08-01 04:00:48
【问题描述】:
首先,我是 node.js 和 discord.js 的初学者。
我目前正在开发我自己的 discord 机器人以获得乐趣,我想知道是否可以“存储”斜杠命令的数据。这是我的意思的一个例子:
const response = new Discord.MessageEmbed()
.properties()
.properties()
etc...
module.exports = () {
const data = {
data: {
type: 4, // I don't know what type to use for embed message so please correct me if I'm wrong
data: {
content: response
}
}
}
}
这是否可以将嵌入消息数据“存储”在rules.js 中并在main.js 中使用它,如下所示:
const rules = require('rules.js') //the file would be in a "commands" folder but I'm keeping this simple
client.ws.on('INTERACTION_CREATE', async (interaction) => {
const command = interaction.data.name.toLowerCase()
if (command === 'rules') {
client.api.interactions(interaction.id, interaction.token).callback.post(data) // or post(rules.data) ??? again, I'm a beginner
}
})
【问题讨论】:
标签: node.js discord.js