.setName在discord.js中不是函数
我已经完成了从YouTube上的教程完成机器人的代码: https://www.youtube 。
4“ rel =“ nofollow noreferrer”> https://replit.com/@tylerlanier/comusity-bot#slash/info.js:6:6:4
我正在遇到此错误:typeeror:((中间值).setName不是“ ...”
的函数,
这是slash/info.js
的代码:
module.exports = {
data: new SlashCommandBuilder()
.setname("info")
.setDescription("Displays info about the currently playing song"),
run: async ({client, interaction}) => {
const queue = client.player.getQueue(interaction.guildId)
if(!queue)
return await interaction.editReply("There are no songs in the queue")
let bar = queue.createProgressBar({
queue: false,
length: 19
})
const song = queue.current
await interaction.editReply({
embeds: [
new MessageEmbed()
.setThumbnail(song.thumbnail)
.setDescription(`Currently Playing [${song.title}](${song.url})\n\n` + bar)
],
})
},
}
I have finished completing the code for my bot from a tutorial on YouTube: https://www.youtube.com/watch?v=fN29HIaoHLU
Here is the entire code on replt.it: https://replit.com/@TylerLanier/Comusity-Bot#slash/info.js:6:4
And I am getting this error: TypeError: (intermediate value).setname is not a function at "..."
Here is the code at slash/info.js
:
module.exports = {
data: new SlashCommandBuilder()
.setname("info")
.setDescription("Displays info about the currently playing song"),
run: async ({client, interaction}) => {
const queue = client.player.getQueue(interaction.guildId)
if(!queue)
return await interaction.editReply("There are no songs in the queue")
let bar = queue.createProgressBar({
queue: false,
length: 19
})
const song = queue.current
await interaction.editReply({
embeds: [
new MessageEmbed()
.setThumbnail(song.thumbnail)
.setDescription(`Currently Playing [${song.title}](${song.url})\n\n` + bar)
],
})
},
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您使用
.setName()
时,错误背后的原因是大写错误。它需要使用资本N为.setName()
。这就是为什么您需要仔细检查代码,以检查每个函数的拼写和调用的变量。您还必须在每个命令中更改此不正确的拼写,除play
命令与每个文件一样,您正在使用.setName()
The reason behind the error is a capitalisation mistake when you use
.setname()
. It needs to be.setName()
with a capital N. This is why you need to go through your code just to check the spelling of each function and variable you call. You will also have to change this incorrect spelling in every command except theplay
command as in each file, you are using.setname()