TobiasGoetz / pibot

A discord bot providing multiple features
0 stars 0 forks source link

reduce code duplication in music cog when checking for player #13

Closed TobiasGoetz closed 1 year ago

TobiasGoetz commented 1 year ago

Is your feature request related to a problem? Please describe. Reduce code duplication when checking if player is defined and/or playing.

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context

await interaction.response.defer()
player: Player = wavelink.NodePool.get_node().get_player(interaction.guild)

if player is None:
    await interaction.followup.send(ERROR_MESSAGE_BOT_NOT_CONNECTED)
    return

if not player.is_playing():
    await interaction.followup.send(ERROR_MESSAGE_NOTHING_PLAYING)
    return
TobiasGoetz commented 1 year ago

Partially improved by better error handling in #10

TobiasGoetz commented 1 year ago

There are a lot of different commands that need different configurations. As of right now I think it is sufficiently reduced.