如何使用Discord机器人嵌入邮件?

编程入门 行业动态 更新时间:2024-10-11 13:22:49
本文介绍了如何使用Discord机器人嵌入邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想编写一个可以将用户发送的消息嵌入特定频道的漫游器.如果您对GTA RP服务器一无所知,那就像是Twitter或Instagram机器人.

I want to code a bot that will embed a user's sent message in a specific channel. If you know anything about GTA RP servers, it's like a Twitter or Instagram bot.

这是一个例子:

我认为这与 console.log 和作者的名字有关,但是我不确定,所以这就是我在这里的原因.如何嵌入用户的消息,例如这个吗?

I think it's something about the console.log and the author's name, but I'm not sure so that's why I'm here. How can I embed users' messages like this?

推荐答案

您可以使用 MessageEmbed ,就像programmergerRaj所说的那样,或使用 MessageOptions :

You can use a MessageEmbed, like programmerRaj said, or use the embed property in MessageOptions:

const {MessageEmbed} = require('discord.js') const embed = new MessageEmbed() .setTitle('some title') .setDescription('some description') .setImage('image url') // These two are the same thing channel.send(embed) channel.send({embed: { title: 'some title', description: 'some description', image: {url: 'image url'} }})

要在特定频道中发送用户信息,您可以执行以下操作,其中 client 是Discord.js Client :

To send an embed of users' message in a particular channel, you can do something like this, where client is your Discord.js Client:

// The channel that you want to send the messages to const channel = client.channels.cache.get('channel id') client.on('message',message => { // Ignore bots if (message.author.bot) return // Send the embed const embed = new MessageEmbed() .setDescription(message.content) .setAuthor(message.author.tag, message.author.displayAvatarURL()) channel.send(embed).catch(console.error) })

请注意,以上代码将发送每条消息,而不是由僵尸程序发送的,因此您可能需要对其进行修改,以使其仅在需要时发送.

Note that the above code will send the embed for every message not sent by a bot, so you will probably want to modify it so that it only sends it when you want it to.

我建议您阅读 Discord.js嵌入指南( archive )或链接的文档上面提供了有关如何使用嵌入的更多信息.

I recommend reading Discord.js' guide on embeds (archive) or the documentation linked above for more information on how to use embeds.

更多推荐

如何使用Discord机器人嵌入邮件?

本文发布于:2023-11-23 13:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621553.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   机器人   邮件   Discord

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!