简体   繁体   English

如何在嵌入中执行 ping

[英]How to do ping in embed

const Discord = require('discord.js')常量 Discord = 要求('discord.js')

const client = new Discord.Client()常量客户端 = 新 Discord.Client()

client.on('ready', () => { client.on('准备好了', () => {

console.log('client'); console.log('client'); }); });

client.on('message', (msg, bot) =>{ client.on('message', (msg, bot) =>{

if (msg.author.bot) return;如果(msg.author.bot)返回;

if (msg.content == 'some com') { if (msg.content == 'some com') {

msg.delete(); msg.delete();

let gifs = [让 gif = [

"some url", “一些网址”,

"some url" ]; “一些网址”];

let pick = gifs[Math.floor(Math.random() * gifs.length)];让pick = gifs[Math.floor(Math.random() * gifs.length)];

let embed = new Discord.MessageEmbed()
embed.setImage(pick);
embed.setTitle(`${msg.author.username} ***some msg***`)
.setColor('#2F3136')
msg.channel.send(embed)
}

}) client.login('token'); }) client.login('token');

i use this code我用这个代码

You can mention a user in an embed.您可以在嵌入中提及用户。 For eg:-例如:-

let embed = new Discord.MessageEmbed()
.setDescription(`${message.authour} this is an example`);
message.channel.send(embed);

But unfortunately, it doesn't ping them.但不幸的是,它不会对它们执行 ping 操作。 So if you want to ping them, you can use:因此,如果要 ping 它们,可以使用:

let embed = new Discord.MessageEmbed()
.setDescription(`This is an example`);
message.channel.send(`${message.authour}`,{embed:embed});

where the mention will be outside the embed.提及将在嵌入之外的地方。

so where do i put it if i have it like this如果我有这样的东西,我应该把它放在哪里

const { MessageEmbed } = require("discord.js") const { MessageEmbed } = 要求(“discord.js”)

module.exports = (client) => { const welcomechannelId = '918552619729969177' //Channel You Want to Send The Welcome Message const targetChannelId = 918562811242758224 //Channel For Rules module.exports = (client) => { const welcomechannelId = '918552619729969177' //您要发送欢迎消息的频道 const targetChannelId = 918562811242758224 //规则频道

client.on('guildMemberAdd', (member) => {
    console.log(member) // If You Want The User Info in Console Who Joined Server Then You Can Add This Line. // Optional
    const channel = member.guild.channels.cache.get(welcomechannelId)

    const embed = new MessageEmbed()
    .setTitle(`Welcome To ${member.guild.name}`)
    .setThumbnail(member.user.displayAvatarURL({dynamic: true, size: 512}))
    .setDescription(`Hello <@${member.user.id}>, Welcome to **${member.guild.name}**. Thanks For Joining Our Server.

Please Read ${member.guild.channels.cache.get(targetChannelId).toString()}.请阅读 ${member.guild.channels.cache.get(targetChannelId).toString()}。 Have a Nice Time.玩得开心。 Chat In <#918839454549033001>`)聊天 <#918839454549033001>`)

    // You Can Add More Fields If You Want
    .setFooter(`Welcome ${member.user.username}#${member.user.discriminator}`,member.user.displayAvatarURL({dynamic: true, size: 512}))
    .setColor('RANDOM')
channel.send(embed)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM