-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
66 lines (54 loc) · 1.88 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import discord
import json
import os
from discord.ext import commands
from discord.ext.commands import MissingPermissions
import discord
import logging
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='.', intents=intents, case_insensitive=True)
client.remove_command("help")
#LOG INTO CONSOLE
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
#Slowdown Message
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.errors.CommandOnCooldown):
if error.retry_after > 60:
minutes = str(error.retry_after // 60)
await ctx.send(f"<a:hourglass:857868080435560520> **| Cooldown:** {minutes} minutes")
else:
await ctx.send(f"<a:hourglass:857868080435560520> **| Cooldown:** {round(error.retry_after)} seconds")
return
#COG COMMANDS
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
await ctx.send("Loaded")
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
await ctx.send("Unloaded")
@client.command()
async def reload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
client.load_extension(f'cogs.{extension}')
await ctx.send("Reloaded")
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
if filename.startswith('__init__'):
pass
client.load_extension(f'cogs.{filename[:-3]}')
#Token
with open('token.json') as f:
data = json.load(f)
token = data["TOKEN"]
client.run(token)