【发布时间】:2020-09-08 10:18:45
【问题描述】:
所以我需要在我的代码中移动 args 两次。这是我到目前为止所拥有的:
const Discord = require('discord.js')
const bot = new Discord.Client()
const token = token here;
const PREFIX = '/';
const embed = new Discord.MessageEmbed()
const ping = require('minecraft-server-util')
bot.on('ready', () => {
console.log('This bot is online! Created by @littleBitsman.');
})
bot.on('message', message => {
let args = message.content.substring(PREFIX.length).split(' ')
if(message.content.startsWith(PREFIX))
switch (args[0]) {
case 'ticket':
if (message.member.roles.highest == '701895573737046066') {
var usertosendto = args[1]
var thing = args.shift().shift()
var embed = new Discord.MessageEmbed()
.setTitle('Ticket')
.setDescription('Hey ' + usertosendto + '! You recieved this ticket because of: ' + thing + '.')
message.channel.send(embed)
}
}
})
bot.login(token);
当我执行args.shift().shift() 时,它显示“TypeError: args.shift(...).shift is not a function”。我该怎么办? (我这里取出了一大块代码)
【问题讨论】:
标签: javascript arrays node.js discord.js