Add sound to och loeh command
This commit is contained in:
BIN
assets/och_loeh.mp3
Normal file
BIN
assets/och_loeh.mp3
Normal file
Binary file not shown.
14
bot.py
14
bot.py
@@ -40,6 +40,8 @@ TOPFIT_WORDS = (
|
|||||||
LOEH_ID = 254265844928872448
|
LOEH_ID = 254265844928872448
|
||||||
OWNER_ID = 327126546970312739
|
OWNER_ID = 327126546970312739
|
||||||
|
|
||||||
|
OCH_LOEH_SOUND = "assets/och_loeh.mp3"
|
||||||
|
|
||||||
last_loeh = 0
|
last_loeh = 0
|
||||||
|
|
||||||
config_load()
|
config_load()
|
||||||
@@ -76,8 +78,16 @@ async def on_message(message: discord.Message):
|
|||||||
loeh = await get_loeh(message.guild)
|
loeh = await get_loeh(message.guild)
|
||||||
if loeh is None:
|
if loeh is None:
|
||||||
await message.channel.send('404: Löh not found!')
|
await message.channel.send('404: Löh not found!')
|
||||||
|
if loeh.voice is None:
|
||||||
|
await message.channel.send('400: Löh not connected!')
|
||||||
else:
|
else:
|
||||||
|
voice: discord.VoiceState = loeh.voice
|
||||||
try:
|
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)
|
await loeh.edit(mute=True)
|
||||||
sleeper = asyncio.sleep(config_get('loeh-timeout', message.guild.id))
|
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)
|
await loeh.edit(mute=False)
|
||||||
if message is not None:
|
if message is not None:
|
||||||
await message.edit(content="~~Zu Befehl!~~\nEs sei ihm verziehen.")
|
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')
|
await message.channel.send('Failed to complete your command, Sir')
|
||||||
return
|
return
|
||||||
elif config_get('inf19x-insiders-enable', message.guild.id):
|
elif config_get('inf19x-insiders-enable', message.guild.id):
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
discord
|
discord
|
||||||
python-dotenv
|
python-dotenv
|
||||||
|
PyNaCl
|
||||||
|
|||||||
Reference in New Issue
Block a user