从机器人 dms DJS 记录照片
Logging Photos from bots dms DJS
我也在尝试在机器人 dms 中记录照片和视频以及消息,我确实尝试过 Discord.MessageAttachment 但这没有正确的目的
if (message.channel.type == 'dm') {
let embed = new Discord.MessageEmbed()
.setAuthor(user)
.setThumbnail(message.author.displayAvatarURL())
.setColor(ee.color)
.setDescription(message.content, Discord.MessageAttachment)
.setFooter(ee.footertext, ee.footericon);
client.channels.cache.get(channelID).send(embed);
if(message.attachments.size > 0) embed.setImage(message.attachments.first().url)
所以我实际上会这样做
对于 Discord v12
if (message.channel.type == 'dm') {
let embed = new Discord.MessageEmbed()
.setAuthor(user)
.setThumbnail(message.author.displayAvatarURL())
.setColor(ee.color)
.setFooter(ee.footertext, ee.footericon)
// just in case they only send an attachment
if (message.content) {
embed.setDescription(message.content)
}
// if they add an image/video/file
if (message.attachments.size > 0) {
if (message.attachments.first().contentType.includes('video')) {
embed.addField('Attached Video', `\u200B`)
client.channels.cache.get(channelID).send({
embed: embed,
files: [message.attachments.first()]
})
} else if (message.attachments.first().contentType.includes('image')) {
embed.addField('Image Below', `\u200B`)
embed.setImage(message.attachments.first().url)
client.channels.cache.get(channelID).send(embed)
} else {
embed.addField('Attached File', `\u200B`)
client.channels.cache.get(channelID).send({
embed: embed,
files: [message.attachments.first()]
})
}
} else {
client.channels.cache.get(channelID).send({
embed: embed
})
}
let embed2 = new Discord.MessageEmbed()
.setTitle('Thank You')
.setColor(ee.color)
.setDescription('Your response is being carefully recorded! <:check:947079937372872704>')
.setFooter(ee.footertext, ee.footericon);
return message.channel.send({
embed: embed2,
component: [button60]
})
}
对于 Discord v13
if (message.channel.type == 'dm') {
let embed = new MessageEmbed()
.setAuthor(user)
.setThumbnail(message.author.displayAvatarURL())
.setColor(ee.color)
.setFooter(ee.footertext, ee.footericon)
// just in case they only send an attachment
if (message.content) {
embed.setDescription(message.content)
}
// if they add an image/video/file
if (message.attachments.size > 0) {
if (message.attachments.first().contentType.includes('video')) {
embed.addField('Attached Video', `\u200B`)
client.channels.cache.get(channelID).send({
embeds: [embed],
files: [message.attachments.first()]
})
} else if (message.attachments.first().contentType.includes('image')) {
embed.addField('Image Below', `\u200B`)
embed.setImage(message.attachments.first().url)
client.channels.cache.get(channelID).send({
embeds: [embed]
})
} else {
embed.addField('Attached File', `\u200B`)
client.channels.cache.get(channelID).send({
embeds: [embed],
files: [message.attachments.first()]
})
}
} else {
client.channels.cache.get(channelID).send({
embeds: [embed]
})
}
let embed2 = new MessageEmbed()
.setTitle('Thank You')
.setColor(ee.color)
.setDescription('Your response is being carefully recorded! <:check:947079937372872704>')
.setFooter(ee.footertext, ee.footericon);
return message.channel.send({
embeds: [embed2],
components: [button60]
})
}
我也在尝试在机器人 dms 中记录照片和视频以及消息,我确实尝试过 Discord.MessageAttachment 但这没有正确的目的
if (message.channel.type == 'dm') {
let embed = new Discord.MessageEmbed()
.setAuthor(user)
.setThumbnail(message.author.displayAvatarURL())
.setColor(ee.color)
.setDescription(message.content, Discord.MessageAttachment)
.setFooter(ee.footertext, ee.footericon);
client.channels.cache.get(channelID).send(embed);
if(message.attachments.size > 0) embed.setImage(message.attachments.first().url)
所以我实际上会这样做
对于 Discord v12
if (message.channel.type == 'dm') {
let embed = new Discord.MessageEmbed()
.setAuthor(user)
.setThumbnail(message.author.displayAvatarURL())
.setColor(ee.color)
.setFooter(ee.footertext, ee.footericon)
// just in case they only send an attachment
if (message.content) {
embed.setDescription(message.content)
}
// if they add an image/video/file
if (message.attachments.size > 0) {
if (message.attachments.first().contentType.includes('video')) {
embed.addField('Attached Video', `\u200B`)
client.channels.cache.get(channelID).send({
embed: embed,
files: [message.attachments.first()]
})
} else if (message.attachments.first().contentType.includes('image')) {
embed.addField('Image Below', `\u200B`)
embed.setImage(message.attachments.first().url)
client.channels.cache.get(channelID).send(embed)
} else {
embed.addField('Attached File', `\u200B`)
client.channels.cache.get(channelID).send({
embed: embed,
files: [message.attachments.first()]
})
}
} else {
client.channels.cache.get(channelID).send({
embed: embed
})
}
let embed2 = new Discord.MessageEmbed()
.setTitle('Thank You')
.setColor(ee.color)
.setDescription('Your response is being carefully recorded! <:check:947079937372872704>')
.setFooter(ee.footertext, ee.footericon);
return message.channel.send({
embed: embed2,
component: [button60]
})
}
对于 Discord v13
if (message.channel.type == 'dm') {
let embed = new MessageEmbed()
.setAuthor(user)
.setThumbnail(message.author.displayAvatarURL())
.setColor(ee.color)
.setFooter(ee.footertext, ee.footericon)
// just in case they only send an attachment
if (message.content) {
embed.setDescription(message.content)
}
// if they add an image/video/file
if (message.attachments.size > 0) {
if (message.attachments.first().contentType.includes('video')) {
embed.addField('Attached Video', `\u200B`)
client.channels.cache.get(channelID).send({
embeds: [embed],
files: [message.attachments.first()]
})
} else if (message.attachments.first().contentType.includes('image')) {
embed.addField('Image Below', `\u200B`)
embed.setImage(message.attachments.first().url)
client.channels.cache.get(channelID).send({
embeds: [embed]
})
} else {
embed.addField('Attached File', `\u200B`)
client.channels.cache.get(channelID).send({
embeds: [embed],
files: [message.attachments.first()]
})
}
} else {
client.channels.cache.get(channelID).send({
embeds: [embed]
})
}
let embed2 = new MessageEmbed()
.setTitle('Thank You')
.setColor(ee.color)
.setDescription('Your response is being carefully recorded! <:check:947079937372872704>')
.setFooter(ee.footertext, ee.footericon);
return message.channel.send({
embeds: [embed2],
components: [button60]
})
}