我不确定问题出在哪里,我不知道这是我的反冲命令还是音乐命令。两者都可以正常工作,所以我需要帮助。我真的不知道该怎么办。我尝试了所有可能想到的方法。他们不是像我所说的那样单独工作,所以我不确定在哪里寻找问题。
if (message.content.startsWith(prefix + "kick")) {
const args = message.content.slice(5).split(" ");
if (!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send("you can\'t use that!");
if (!message.guild.me.hasPermission("KICK_MEMBERS")) return message.channel.send("I don\'t have the right permissions.");
const member = message.mentions.members.first() || message.guild.members.cache.get(args[1]);
if (!args[1]) return message.channel.send("Please specify a user");
if (!member) return message.channel.send("cannot seem to find this user. Sorry about that.");
if (!member.kickable) return message.channel.send("This user cannot be kicked. It is because they are a higher role, or have the same role.");
if (!member.id === message.author.id) return message.channel.send("Bruh, you cannot kick yourself...");
let reason = args.slice(2).join(" ");
}
if (!reason) reason = 'NONE';
member.kick(reason)
.catch(error => {
if (error) return message.channel.send("Something went wrong.")
})
const kickembed = new Discord.MessageEmbed()
.setAuthor(botname, avatarurl)
.setTitle('Member Kicked')
.setThumbnail(member.user.displayAvatarURL())
.setColor(color)
.addField('User Kicked', member)
.addField('Kicked by', message.author)
.addField('Reason', reason)
.setFooter(`${botname} | Time kicked`, botname.user.displayAvatarURL())
.setTimestamp()
message.channel.send(kickembed);
const ServerQueue = queue.get(message.guild.id);
if (message.content.startsWith(`${prefix}play`)) {
return execute(message, ServerQueue);
}
if (message.content.startsWith(`${prefix}skip`)) {
return skip(message, ServerQueue);
return;
}
if (message.content.startsWith(`${prefix}stop`)) {
return stop(message, ServerQueue);
return;
} else {
return message.reply("not a valid command")
}
});
async function execute(message, ServerQueue) {
const args = message.content.split(" ");
const voiceChannel = message.member.voice.channel;
if (!voiceChannel)
return message.reply("You must be in a voice channel.");
if (args[1] === undefined) return message.reply("Please provide a link!");
//if(!args[1].content.include("youtube")) return message.reply("Please use a valid link");
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has("CONNECT") || !permissions.has("SPEAK")) return message.reply("IM MISSING PERMISSIONS");
const songInfo = await ytdl.getInfo(args[1])
const song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url,
}
if (!ServerQueue) {
const queueConstruct = {
textChannel: message.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true
};
queue.set(message.guild.id, queueConstruct)
queueConstruct.songs.push(song);
try {
var connection = await voiceChannel.join();
await connection.voice.setSelfDeaf(true);
queueConstruct.connection = connection;
play(message.guild, queueConstruct.songs[0])
} catch {
console.log(error);
queue.delete(message.guild.ig);
return message.reply(error);
}
} else {
ServerQueue.songs.push(song);
return message.channel.send(`${song.title} has been added to the queue! `);
}
}
function skip(message, ServerQueue) {
if (!message.member.voice.channel)
return message.reply("Join VC to Skip!");
if (!ServerQueue) return message.reply("Nothing playing!");
ServerQueue.connection.dispatcher.end();
}
function stop(message, ServerQueue) {
if (!message.member.voice.channel)
return message.reply("Join VC to Skip!");
if (!ServerQueue) return message.reply("Nothing playing!");
ServerQueue.songs = [];
ServerQueue.connection.dispatcher.end();
}
function play(guild, song) {
const ServerQueue = queue.get(guild.id);
if (!song) {
ServerQueue.voiceChannel.leave();
queue.delete(guild.id);
return;
}
const dispatcher = ServerQueue.connection
.play(ytdl(song.url))
.on("finish", () => {
ServerQueue.songs.shift();
play(guild, ServerQueue.songs[0]);
})
.on("error", error => console.error(error));
dispatcher.setVolumeLogarithmic(ServerQueue.volume / 5);
ServerQueue.textChannel.send(`Now playing: **${song.title}**`)
}