-
Notifications
You must be signed in to change notification settings - Fork 9
/
Run.py
75 lines (59 loc) · 1.87 KB
/
Run.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
67
68
69
70
71
72
73
74
75
import discord
import os
from discord.ext import commands, tasks
from discord.utils import get
import asyncio
import json
import Cogs.Json.jshelper as jshelper
import sys
jshelper.prestart()
data = jshelper.openf("/config/config.json")
if data["token"] == "":
print("Missing Config.")
sys.exit()
data = jshelper.openf("/config/config.json")
TOKEN = data["token"]
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=".", intents = intents)
bot.remove_command('help')
@bot.event
async def on_ready():
print("bot is online.")
@bot.command()
@commands.has_permissions(administrator=True)
async def load(ctx, name):
bot.load_extension(f'Cogs.{name}')
print(f"The {name} cog has been loaded successfully.")
@bot.command()
@commands.has_permissions(administrator=True)
async def unload(ctx, name):
bot.unload_extension(f'Cogs.{name}')
print(f"The {name} cog has been unloaded successfully.")
@bot.command()
@commands.has_permissions(administrator=True)
async def reload(ctx, name):
bot.unload_extension(f'Cogs.{name}')
bot.load_extension(f'Cogs.{name}')
print(f"The {name} cog has been reloaded successfully.")
@bot.event
async def on_message(message):
if message.author.id == bot.user.id:
return
if not message.guild:
return
await bot.process_commands(message)
@bot.command()
@commands.has_permissions(administrator=True)
async def all(ctx):
for filename in os.listdir("Cogs"):
if filename.endswith('.py'):
bot.unload_extension(f'Cogs.{filename[:-3]}')
for filename in os.listdir("Cogs"):
if filename.endswith('.py'):
bot.load_extension(f'Cogs.{filename[:-3]}')
print("All cogs has been reloaded.")
for filename in os.listdir("Cogs"):
if filename.endswith('.py'):
bot.load_extension(f'Cogs.{filename[:-3]}')
bot.run(TOKEN)