Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未经处理的PromisejectionWarning:DiscordAPIError:无法编辑其他用户编写的邮件_Javascript_Discord_Discord.js_Bots - Fatal编程技术网

Javascript 未经处理的PromisejectionWarning:DiscordAPIError:无法编辑其他用户编写的邮件

Javascript 未经处理的PromisejectionWarning:DiscordAPIError:无法编辑其他用户编写的邮件,javascript,discord,discord.js,bots,Javascript,Discord,Discord.js,Bots,我正在做一个项目,基本上我正在尝试让一个音乐不和谐机器人播放我创建的播放列表。这是在discord javascript中,并且正在使用npm exports.run=async(客户端、消息、参数)=>{ 如果(!message.member.voice.channel)返回message.channel.send(`${client.emotes.error}-您不在语音频道中!`); if(!args[0])返回message.channel.send(`${client.emotes.e

我正在做一个项目,基本上我正在尝试让一个音乐不和谐机器人播放我创建的播放列表。这是在discord javascript中,并且正在使用npm

exports.run=async(客户端、消息、参数)=>{
如果(!message.member.voice.channel)返回message.channel.send(`${client.emotes.error}-您不在语音频道中!`);
if(!args[0])返回message.channel.send(`${client.emotes.error}-请指明歌曲的标题!`);
message.edit(“**!播放hello**”)
client.player.play(消息,args.join(“”,{firstResult:true});
};

此外,我知道没有办法实际编辑消息,但是,我控制bot,所以我可以使用bot id或其他东西来更改变量消息吗?任何想法都很好,谢谢

您不能编辑非bot编写的消息。处理程序的箭头函数中导出了参数
message
,该函数表示用户而非bot发送的消息/命令。要编辑bot的消息,您可以应用以下更改:

message.channel.send(`${client.emotes.error}-请指明歌曲的标题!`)。然后((editthis)=>{
editthis.edit(`看起来我们现在有一条经过编辑的消息')
}); 

基本上,
.send()
方法返回一个带有已发送消息对象的承诺,这里我们将该对象定义为
editthis
,并进一步使用解析过程中传递的
editthis
参数解析该承诺并进行编辑(我们要编辑的消息对象)。

如果您不是消息的所有者/发送者,那么这条消息就不能编辑了。谢谢,我的人真的很感激,有一个问题,有没有办法阻止“看起来我们现在有一条编辑过的消息”被打印出来?非常感谢,你是一个救生员。只需在
.edit()
方法中替换它,如果有帮助,你可以将我的答案标记为正确:)