Skip to content

discord-player@6.6.8

Compare
Choose a tag to compare
@twlite twlite released this 01 Apr 17:44
· 14 commits to master since this release

New hooks api

Good to know: Previous hooks api is still valid and works as expected.

Previously, hooks required you to pass guild/id as an argument which is expressed as:

const queue = useQueue(interaction.guild.id);

With the new update, there is another method of using hooks, which does not require you to pass guild/id as an argument. In other words, the following code will automatically get the correct queue.

const queue = useQueue();

In order to use this method for hooks, you will need to update your command handler to execute your command with hooks context, which can be written as:

// assuming the following is our command to be executed
const command = getCommandToExecute();

// we would normally execute it as
await command.execute(interaction);

// instead, we have to use the following
const ctx = { guild: interaction.guild };
await player.context.provide(ctx, () => command.execute(interaction));

This would allow every command to use discord-player hooks without having to specify guild/id.

Why is this necessary?

Lets say you have a command and it calls utility function(s) and that utility function also requires access to discord-player data. You'd normally pass it down through arguments over and over again until it reaches the destination. But with this api, you do not need to pass it down via arguments. It will be directly available to the destination.

Changelog

New Contributors

Full Changelog: https://github.com/Androz2091/discord-player/compare/@discord-player/extractor@4.4.7...discord-player@6.6.8