-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanage.py
56 lines (49 loc) · 2.06 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import discord
import asyncio
from discord.ext import commands
from config import config, DLDIR
class Manage(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(name='set-prefix')
@commands.has_permissions(manage_messages=True)
async def set_prefix(self, context, query: str = None):
if " " in query:
return await context.send("Préfixe invalide")
prefix = query
await self.bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=prefix+"help"))
config.setPrefix(prefix)
return await context.send("Le Préfixe à été défini sur %s" % (prefix))
@set_prefix.error
async def set_prefix_error(self, context, error):
if isinstance(error, commands.MissingPermissions):
return await context.send("Vous n'avez pas la permission d'éxécuter cette commande !")
@commands.command(aliases=['hutdown'])
@commands.is_owner()
async def shutdown(self, context):
authorVoice = context.author.voice
voiceClient = context.voice_client
if authorVoice is not None:
if voiceClient is not None:
await voiceClient.move_to(authorVoice.channel)
else:
voiceClient = await authorVoice.channel.connect(timeout=600, reconnect=True)
if voiceClient is not None:
if voiceClient.is_playing():
voiceClient.stop()
player = discord.FFmpegPCMAudio(os.path.dirname(os.path.realpath(__file__)) + "/shutdown.webm", options="-vn")
voiceClient.play(player)
while voiceClient.is_playing():
pass
await voiceClient.disconnect()
await context.send("Adios...")
for f in os.listdir(DLDIR):
os.remove(DLDIR + f)
exit(0)
@shutdown.error
async def shutdown_error(self, context, error):
if isinstance(error, commands.NotOwner):
return await context.send("Je ne répond qu'au maître")
else:
print(error)