javascript - 如何制作一个不和谐的机器人来复制带有 ID 的用户名?
问题描述
我需要帮助。我想制作一个不和谐的机器人,它可以复制带有 ID 的用户名并在第二个中将其作为文本文件发送。我试图这样做,但无济于事。
示例:用户名:使用的 ID
if (message.content === '16') {
if (!devs.includes(message.author.id)) return;
if (message.channel.type === "dm") return;
client.on("message", (message) => {
if (message.channel.type === "dm") {
if (message.author.id != client.user.id) {
let yumz = new Discord. ( guild.members.username, guild.members.id)
client.channels.find(e=>e.id === '75759********20').send(file.txt);
}
}
});
解决方案
要发送文本文件,您只需send()
:MessageFile
// get the text content to send as a file
const text = `${message.author.username}: ${message.author.id}`;
// create the message file data
const MessageFile = {
attachment: Buffer.from(text)
};
// Send the file!
channel.send({
files: [MessageFile]
});
此答案假定为最新discord.js
版本(v13)。
推荐阅读
- c# - Unity/C# Camera Culling Mask Notation
- java - 在使用 ThreeTen-Backport 与 java.time 时,您是否应该完全限定包前缀?
- xml - 将行号添加到 XSL-FO 文档
- android - 生成签名的 apk 后 GoogleSignInAccount 不起作用
- actions-on-google - 使用 openUrlAction 发送 LinkOutSuggestion 的正确方法是什么?
- r - R,标准输入到 Rscript
- c# - 在 Visual Studio C# 项目中管理资源(图像、文本文件),无需将绝对路径硬编码到源代码中
- reactjs - Webpack+ tsconfig + 动态导入对 .d.ts 文件抛出 NoEmit 错误
- hibernate - 如果违反了 2 列的唯一约束,则休眠更新
- java - Android:在 Java 中使用 RadioButton.isChecked() 方法