Add sound to och loeh command
This commit is contained in:
14
bot.py
14
bot.py
@@ -40,6 +40,8 @@ TOPFIT_WORDS = (
|
||||
LOEH_ID = 254265844928872448
|
||||
OWNER_ID = 327126546970312739
|
||||
|
||||
OCH_LOEH_SOUND = "assets/och_loeh.mp3"
|
||||
|
||||
last_loeh = 0
|
||||
|
||||
config_load()
|
||||
@@ -76,8 +78,16 @@ async def on_message(message: discord.Message):
|
||||
loeh = await get_loeh(message.guild)
|
||||
if loeh is None:
|
||||
await message.channel.send('404: Löh not found!')
|
||||
if loeh.voice is None:
|
||||
await message.channel.send('400: Löh not connected!')
|
||||
else:
|
||||
voice: discord.VoiceState = loeh.voice
|
||||
try:
|
||||
voice_channel: discord.VoiceChannel = voice.channel
|
||||
voice_protocol: discord.VoiceProtocol = await voice_channel.connect()
|
||||
if type(voice_protocol) is discord.VoiceClient:
|
||||
source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(source=OCH_LOEH_SOUND))
|
||||
voice_protocol.play(source)
|
||||
await loeh.edit(mute=True)
|
||||
sleeper = asyncio.sleep(config_get('loeh-timeout', message.guild.id))
|
||||
|
||||
@@ -86,7 +96,9 @@ async def on_message(message: discord.Message):
|
||||
await loeh.edit(mute=False)
|
||||
if message is not None:
|
||||
await message.edit(content="~~Zu Befehl!~~\nEs sei ihm verziehen.")
|
||||
except (discord.Forbidden, discord.HTTPException):
|
||||
if type(voice_protocol) is discord.VoiceClient:
|
||||
await voice_protocol.disconnect()
|
||||
except (asyncio.TimeoutError, discord.Forbidden, discord.HTTPException, discord.ClientException):
|
||||
await message.channel.send('Failed to complete your command, Sir')
|
||||
return
|
||||
elif config_get('inf19x-insiders-enable', message.guild.id):
|
||||
|
||||
Reference in New Issue
Block a user