-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
50 lines (41 loc) · 1.25 KB
/
main.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
import discord
import os
import asyncio
from discord.ext import commands
from discord.ext import tasks
import config
TOKEN = config.TOKEN
ID = config.ID
async def main():
#start client
async with client:
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await client.load_extension(f'cogs.{filename[:-3]}')
await client.start(TOKEN)
intents = discord.Intents().all()
client = commands.Bot(command_prefix="-", intents=intents)
@client.event
async def on_ready():
try:
synced = await client.tree.sync()
print(f"Sycned {len(synced)} commands!")
except Exception as e:
print(e)
print('I am ready')
@client.command()
async def load(ctx, extension):
if ctx.author.id == ID:
await client.load_extension(f'cogs.{extension}')
await ctx.send(f'{extension} loaded.')
if ctx.author.id != ID:
await ctx.send('no')
@client.command()
async def unload(ctx, extension, avamember : discord.Member=None):
if ctx.author.id == ID:
await client.unload_extension(f'cogs.{extension}')
await ctx.send(f'{extension} unloaded.')
if ctx.author.id != ID:
await ctx.send('no')
discord.utils.setup_logging()
asyncio.run(main())