首页 > 解决方案 > 如何制作一个不和谐的机器人来复制带有 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);

     }       
   }
 });

标签: javascriptdiscord.js

解决方案


要发送文本文件,您只需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)。


推荐阅读