KagChi / noteblock

A open-source music bot based on lavalink.
GNU General Public License v3.0
116 stars 110 forks source link

skip and forceskip commands #32

Closed Koelinator closed 3 years ago

Koelinator commented 3 years ago

Maybe an idea to add the ability to have the "skip" command work in a way so multiple people have to use the command.

Second command for X role (multiple roles) "forceskip"

KagChi commented 3 years ago

wdym for x role, spesific roles?

Koelinator commented 3 years ago

Already got the forceskip command working:

const { CreateEmbed } = require('../../Utility/CreateEmbed');
const { Permissions } = require('discord.js');

module.exports = class ForceSkipCommand extends Command {
  constructor() {
    super('forceskip', {
      aliases: ['forceskip', 'fs'],
      description: {
        content: 'Forceskip a song',
      },
      category: 'Music',
      cooldown: 3000,
    });
  }

  async exec(msg) {
    try {
      const GuildPlayers = this.client.erela.players.get(msg.guild.id);
      if (msg.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) {
      } else if (msg.member.roles.cache.some(role => role.name === 'DJ')) {
      } else {
        return msg.channel.send({ embeds: [CreateEmbed('warn', '⛔ | You do not have the permissions to use this command')] })
      };
      if (!GuildPlayers) return msg.channel.send({ embeds: [CreateEmbed('info', '⛔ | There no music playing in this guild')] });
      if (!msg.member.voice.channelId) return msg.channel.send({ embeds: [CreateEmbed('warn', '⛔ | you must join voice channel to do this.')] });
      if (msg.member.voice.channelId !== GuildPlayers.voiceChannel) return msg.channel.send({ embeds: [CreateEmbed('warn', '⛔ | you must join voice channel same as me to do this.')] });
      GuildPlayers.stop();
      return msg.channel.send({ embeds: [CreateEmbed('info', '👌 | Force skipped current song')] });
    } catch (e) {
      this.client.logger.error(e.message);
      return msg.channel.send({ embeds: [CreateEmbed('warn', '⛔ | An error occured')] });
    }
  }
};

I did notice that if the command is used again after less then 3 seconds the bot crashes so that would be something you could look into.

KagChi commented 3 years ago

I did notice that if the command is used again after less then 3 seconds the bot crashes so that would be something you could look into.

can you show the error log?

Koelinator commented 3 years ago
C:\Users\%USERNAME%\Desktop\noteblock-main\noteblock-main\node_modules\discord.js\src\rest\RequestHandler.js:298
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (C:\Users\%USERNAME%\Desktop\noteblock-main\noteblock-main\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\%USERNAME%\Desktop\noteblock-main\noteblock-main\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
    at async TextChannel.send (C:\Users\%USERNAME%\Desktop\noteblock-main\noteblock-main\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:171:15)
    at async CommandHandler.<anonymous> (C:\Users\%USERNAME%\Desktop\noteblock-main\noteblock-main\src\Struct\NoteClient.js:58:24) {
  method: 'post',
  path: '/channels/873260131058602045/messages',
  code: 50006,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}

%username% is of course the folder of the user in windows.

I have a live version running on Ubuntu 20.04 LTS with the same error only with other directories.

KagChi commented 3 years ago

could not reproduce your error image

Koelinator commented 3 years ago

Have you tried adding a few songs and just skipping through a few of them?

KagChi commented 3 years ago

adding few tracks has nothing to do with

DiscordAPIError: Cannot send an empty message

KagChi commented 3 years ago

hey, DiscordAPIError: Cannot send an empty message was fixed in latest commit. can you reproduce again?

Koelinator commented 3 years ago

Problem seems to be solved.