Add sound to och loeh command

This commit is contained in:
2021-01-14 12:47:06 +01:00
parent 68fb3eb0ee
commit 90577e7b9d
3 changed files with 14 additions and 1 deletions

BIN
assets/och_loeh.mp3 Normal file

Binary file not shown.

14
bot.py
View File

@@ -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):

View File

@@ -1,2 +1,3 @@
discord
python-dotenv
PyNaCl