1
0
Fork 0
mirror of https://gitlab.jonasled.de/jonasled/discordbot synced 2024-10-03 07:48:58 +02:00

check if user is connected to voice channel, if using VC commands

This commit is contained in:
Jonas Leder 2020-09-28 20:54:01 +02:00
parent 1c37859061
commit 57f495ae37

16
bot.py
View file

@ -491,6 +491,11 @@ async def play(ctx, songURL : str):
@bot.command(brief="skipps the current song in playlist")
async def skip(ctx):
try:
channel = ctx.author.voice.channel#get the current voicechat the user is in
except:#if we can't get the voice channel, the user is not in one ==> print an error
await ctx.message.channel.send("To use the music bot you have to be in a voice chat")
return
if reactOnValidCommand: await ctx.message.add_reaction("")
global player# import the global variable
player.stop()#stop the player (daemon think song enden ==> plays next one)
@ -510,6 +515,11 @@ async def que(ctx):
@bot.command(brief="stop the music bot and clear the que")
async def stop(ctx):
if reactOnValidCommand: await ctx.message.add_reaction("")
try:
channel = ctx.author.voice.channel#get the current voicechat the user is in
except:#if we can't get the voice channel, the user is not in one ==> print an error
await ctx.message.channel.send("To use the music bot you have to be in a voice chat")
return
global player#import the global variables
global playerQue
global titleQue
@ -533,6 +543,12 @@ async def stop(ctx):
@bot.command(brief="changes the volume of the music bot")#with this command you can change the volume of the music bot
async def volume(ctx, volume : int):
if reactOnValidCommand: await ctx.message.add_reaction("")
try:
channel = ctx.author.voice.channel#get the current voicechat the user is in
except:#if we can't get the voice channel, the user is not in one ==> print an error
await ctx.message.channel.send("To use the music bot you have to be in a voice chat")
return
global audioPlayer#import hte global audio player
if(volume < 0) or (volume > 100):#check if the volume is in a percent range
ctx.message.channel.send("Volume has to be between 0 and 100")