This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
70 lines (50 loc) · 2.34 KB
/
bot.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
from shutil import ExecError
from discord.commands import slash_command
from discord.ext import commands
import discord
import json
import os
def read_config():
os.chdir(os.path.dirname(__file__))
# Reading Config File
with open("config.json", "r") as config:
config = json.load(config)
return config
config = read_config()
# Defining all variables
PREFIX = "%"
TESTING_GUILD_ID = config["guild_ids"]
TOKEN = config["token"]
DESCRIPTION = """This is a simple Bot which can play music, access the r6tracker networks database, administrate your server and much much more..... """
INTENTS = discord.Intents.default()
INTENTS.message_content = True
INTENTS.members = True
INTENTS.presences = True
bot = commands.Bot(command_prefix=PREFIX, description=DESCRIPTION, intents=INTENTS)
bot.remove_command('help')
# Loading the Extensions aka. cogs
registered_extensions = ['cogs.main', 'cogs.music', '!cogs.r6tracker', 'cogs.slash', 'cogs.twitch', '!cogs.music2', 'cogs.voice_recognition']
for extension in registered_extensions:
if extension.startswith('!'):
print(f"\033[31m[-]\033[00m Extension skipped: {extension.replace('!','')}")
else:
bot.load_extension(extension)
print(f"\033[92m[+]\033[00m Extension loaded: {extension}")
@bot.slash_command(guild_ids=config["guild_ids"], description="Loads the given cog (this can break some extensions, be careful what you do!)")
async def load_cog(ctx, cog_name: str):
if ctx.author.guild_permissions.administrator:
bot.load_extension(cog_name)
await ctx.respond(f"The Cog: `{cog_name}` has been loaded", ephemeral=True)
else:
await ctx.respond("You dont have the permission to manage Cogs", ephemeral=True)
@bot.slash_command(guild_ids=config["guild_ids"], description="Unloads the given cog (this can break some extensions, be careful what you do!)")
async def unload_cog(ctx, cog_name: str):
if ctx.author.guild_permissions.administrator:
try:
bot.unload_extension(cog_name)
await ctx.respond(f"The Cog: `{cog_name}` has been unloaded", ephemeral=True)
except discord.errors.ExtensionNotLoaded:
await ctx.respond(f"The Cog: `{cog_name}` was never loaded", ephemeral=True)
else:
await ctx.respond("You dont have the permission to manage Cogs", ephemeral=True)
bot.run(TOKEN)