大佬教程收集整理的这篇文章主要介绍了Discord.js 无法发送空消息,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在尝试发送我的不和谐嵌入。但它不会发送,它总是错误。错误看起来像这样
discordAPIError: CAnnot send an empty message
at requestHandler.execute (C:\Users\me\documents\npm-test\node_modules\discord.Js\src\rest\requestHandler.Js:154:13)
at processticksAndRejections (node:internal/process/task_queues:94:5)
at async requestHandler.push (C:\Users\me\documents\npm-
test\node_modules\discord.Js\src\rest\requestHandler.Js:39:14) {
method: 'post',path: '/chAnnels/808286362100564002/messages',code: 50006,httpStatus: 400
}
但是如果我尝试 console.log
messageEmbed 对象,我会得到这个
messageEmbed {
type: 'rich',title: 'what a cool embed',description: 'It has a descriptionfalse',url: null,color: 15417396,timestamp: 1617041078103,fIElds: [],thumbnail: null,image: null,vIDeo: null,author: null,provIDer: null,footer: { text: 'Even a footer',iconURL: undefined },files: []
}
我不知道这个问题的原因是什么,我试图在这里遵循其他人的解决方案,但没有任何效果):
我的自定义课程
constructor(question: String,type: "number" | "String",optional: Boolean,timeout?: number,description?: String,url?: String,color?: String | number | [number,number,number],timestamp?: Date,footer?: String){
this.question = question;
this.type = type;
this.optional = optional;
this.timeout = timeout;
this.description = description;
thiS.Url = url;
this.color = color;
this.timestamp = timestamp;
this.footer = footer;
}
getEmbed(): messageEmbed{
const Embed = new messageEmbed()
Embed.settitle(this.question)
if(this.description) {Embed.setDescription(this.description + this.optional)}
if(thiS.Url) {Embed.setURL(thiS.Url)}
if(this.color) {Embed.setcolor(this.color)}
if(this.timestamp) {Embed.settimestamp(this.timestamp)}
if(this.footer) {Embed.setFooter(this.footer)}
return Embed
}
客户端代码
let question = new PromptQuestion("what a cool embed","number",false,20,"It has a description",null,[235,64,52],Date.Now(),"Even a footer")
let embed = question.getEmbed()
console.log(embed)
clIEnt.on("message",m => {
if(m.author.bot) { return }
m.reply(embed)
})
我想通了,或者至少是修复了。
而不是返回 embed
return new messageEmbed(embed)
就我而言,问题原来是我在频道中没有权限!权限与嵌入/外部内容有关,因此 Discord 可能由于缺少权限而默默删除了嵌入,然后由于空消息而出错。在某些消息组合最终闪现丢失权限错误后,我得到提示,这是权限。
TL;DR:检查您的权限,我们的频道除了发送拒绝消息外,还有一切,这不是一个好主意。
如果不确定,请尝试不同的频道或在 PM 中发送消息(例如 @H_652_5@msg.author.send)
以上是大佬教程为你收集整理的Discord.js 无法发送空消息全部内容,希望文章能够帮你解决Discord.js 无法发送空消息所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。