discord - 将 DMed 文件和链接发送到服务器中的频道
问题描述
好的。这可能是一个奇怪的问题,但我需要帮助,因为我在网上找不到任何东西。我有一个不和谐的机器人和服务器来举办比赛,用户通过直接向我发送他们提交的链接或文件来提交他们的提交。我想将其更改为他们对机器人进行 DM,然后机器人将链接和文件发布到服务器的某个频道中。我完全不知道如何实现这一点,因为当涉及到这类事情时,我是一个新手。如果我需要更改措辞或需要澄清任何事情,请发表评论!
解决方案
替换channel id
为您要将提交发送到的频道的实际 ID。
对于 Discord.js v12/v13(最新版本):
client.on('message', ({attachments, author, content, guild}) => {
// only do this for DMs
if (!guild) {
// this will simply send all the attachments, if there are any, or the message content
// you might also want to check that the content is a link as well
const submission = attachments.size
? {files: [...attachments.values()], content: `${author}`}
: {content: `${content}\n${author}`}
client.channels.cache.get('channel id').send(submission)
}
})
对于 Discord.js v11 替换
client.channels.cache.get('channel id').send(submission)
和
client.channels.get('channel id').send(submission)
推荐阅读
- r - 在 R 中使用 k-NN 进行交叉验证时如何构造混淆矩阵
- react-native - React Navigation - 在选项卡之间跳转
- java - 如何解决 java 流的意外行为?
- error-handling - apex addError - 删除默认错误消息
- c - 使用 libevdev 跟踪多个着陆/上升
- forms - 如何以嵌入形式从非映射字段中检索数据
- google-cast - 如何获取在 chromecast 设备上崩溃的 Receiver 应用程序的崩溃日志?
- azure - 使用 Azure CLI 列出超过 5000 个 blob 时,如何消除 Powershell 中的错误消息?
- grails - Grails:如何向 F:Table 添加参数
- ionic3 - 我在为 ios 编译 ionic 3 应用程序时出错,无法安装“onesignal-cordova-plugin”:未定义