KagChi/noteblock

skip and forceskip commands

Closed this issue · 9 comments

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"

wdym for x role, spesific roles?

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.

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?

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.

could not reproduce your error
image

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

adding few tracks has nothing to do with

DiscordAPIError: Cannot send an empty message

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

Problem seems to be solved.