Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not playing audio. [Fixed] #6

Closed
MoonCarli opened this issue Feb 21, 2024 · 1 comment
Closed

Not playing audio. [Fixed] #6

MoonCarli opened this issue Feb 21, 2024 · 1 comment
Assignees
Labels
bug Something isn't working fixed

Comments

@MoonCarli
Copy link

Issue description

My lavalink is working fine, my code is fine but the bot is not playing audio dont know why..
Screenshot 2024-02-21 224646

Code sample

const { Client, EmbedBuilder, PermissionFlagsBits } = require("discord.js");

module.exports = {
  name: "play",
  category: "Music",
  aliases: ["p"],
  clientPermissions: [PermissionFlagsBits.Connect, PermissionFlagsBits.Speak],
  description: "Play songs",
  inVoice: true,

  execute: async (message, args, client) => {
    /**
     *
     * @param {Client} client
     * @param {CommandInteraction} interaction
     * @param {String} args
     * @returns
     */

    const query = args.join(' ');
    
    //This will not load the third-party link
    if (query.includes(`bit.ly`)) {
      return message.channel.send({
        embeds: [
          new EmbedBuilder()
            .setColor(client.embedColor)
            .setDescription(`**We Don't Support This Link**`),
        ],
      });
    }

    let player = client.riffy.players.get(message.guildId);

    if (!player)
      player = await client.riffy.createConnection({
        guildId: message.guild.id,
        voiceChannel: message.member.voice.channel.id,
        textChannel: message.channel.id,
        deaf: true,
      });

    const resolve = await client.riffy.resolve({
      query: query,
      requester: message.author,
    });
    const { loadType, tracks, playlistInfo } = resolve;

    if (loadType === "PLAYLIST_LOADED") {
      for (const track of resolve.tracks) {
        track.info.requester = message.author;
        player.queue.add(track);
      }

      await message.reply(
        `Added ${tracks.length} songs from ${playlistInfo.name} playlist.`
      );

      if (!player.playing && !player.paused) return player.play();
    } else if (loadType === "SEARCH_RESULT" || loadType === "TRACK_LOADED") {
      const track = tracks.shift();
      track.info.requester = message.author;

      player.queue.add(track);

      await message.reply(`Added **${track.info.title}** to the queue.`);

      if (!player.playing && !player.paused) return player.play();
    } else {
      return message.reply(`There were no results found for your query.`);
    }
  },
};

Versions

"discord.js": "14.11",
"fs": "^0.0.1-security",
"musicard": "^2.0.3",
"riffy": "^1.0.3",
"riffy-spotify": "^1.0.2"

Issue priority

High (immediate attention needed)

@MoonCarli MoonCarli added the bug Something isn't working label Feb 21, 2024
@UnschooledGamer
Copy link
Member

Issue description

My lavalink is working fine, my code is fine but the bot is not playing audio dont know why..
Screenshot 2024-02-21 224646

Code sample

const { Client, EmbedBuilder, PermissionFlagsBits } = require("discord.js");

module.exports = {
  name: "play",
  category: "Music",
  aliases: ["p"],
  clientPermissions: [PermissionFlagsBits.Connect, PermissionFlagsBits.Speak],
  description: "Play songs",
  inVoice: true,

  execute: async (message, args, client) => {
    /**
     *
     * @param {Client} client
     * @param {CommandInteraction} interaction
     * @param {String} args
     * @returns
     */

    const query = args.join(' ');
    
    //This will not load the third-party link
    if (query.includes(`bit.ly`)) {
      return message.channel.send({
        embeds: [
          new EmbedBuilder()
            .setColor(client.embedColor)
            .setDescription(`**We Don't Support This Link**`),
        ],
      });
    }

    let player = client.riffy.players.get(message.guildId);

    if (!player)
      player = await client.riffy.createConnection({
        guildId: message.guild.id,
        voiceChannel: message.member.voice.channel.id,
        textChannel: message.channel.id,
        deaf: true,
      });

    const resolve = await client.riffy.resolve({
      query: query,
      requester: message.author,
    });
    const { loadType, tracks, playlistInfo } = resolve;

    if (loadType === "PLAYLIST_LOADED") {
      for (const track of resolve.tracks) {
        track.info.requester = message.author;
        player.queue.add(track);
      }

      await message.reply(
        `Added ${tracks.length} songs from ${playlistInfo.name} playlist.`
      );

      if (!player.playing && !player.paused) return player.play();
    } else if (loadType === "SEARCH_RESULT" || loadType === "TRACK_LOADED") {
      const track = tracks.shift();
      track.info.requester = message.author;

      player.queue.add(track);

      await message.reply(`Added **${track.info.title}** to the queue.`);

      if (!player.playing && !player.paused) return player.play();
    } else {
      return message.reply(`There were no results found for your query.`);
    }
  },
};

Versions

"discord.js": "14.11",
"fs": "^0.0.1-security",
"musicard": "^2.0.3",
"riffy": "^1.0.3",
"riffy-spotify": "^1.0.2"

Issue priority

High (immediate attention needed)

Show me initialisation of Riffy & raw event code.

@MoonCarli MoonCarli changed the title Not playing audio. Not playing audio. [Fixed] Feb 25, 2024
@flameface flameface self-assigned this Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

3 participants