-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
116 lines (98 loc) · 3.78 KB
/
bot.py
File metadata and controls
116 lines (98 loc) · 3.78 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import discord
from cogs.config import config
import yaml
from discord.ext import commands
# noinspection PyBroadException
def getPrefix(bot, message):
if type(message) == str or int:
guildID = message
else:
guildID = str(message.guild.id)
try:
prefixes = config.load("prefixes")
return prefixes[guildID]
except:
return "d."
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=getPrefix, intents=intents)
bot.remove_command("help")
@bot.event
async def on_ready():
with open("cogs.yaml", "r") as f:
cogList = yaml.safe_load(f)
for cog in cogList["cogs"]:
if cogList["cogs"][cog]["enabled"]:
bot.load_extension(f"cogs.{cog}")
print(cog)
print("¡Todos los módulos cargados!")
print(f"¡Listo! ¡{bot.user} está online!")
activity = discord.Activity(name='yeet', type=discord.ActivityType.streaming)
await bot.change_presence(activity=activity)
@bot.event
async def on_message(message):
print(message.author, "dijo '", message.content, "' en el canal", message.channel, "(ID:", message.channel.id, ")")
await bot.process_commands(message)
@bot.command(name="load", hidden=True)
async def load(ctx, modulo):
if ctx.author.id == 439470338150236162:
try:
bot.load_extension(f"cogs.{modulo}")
await ctx.send(f"Módulo {modulo} cargado correctamente!")
print(f"Módulo {modulo} cargado correctamente!")
except discord.ext.commands.errors.ExtensionNotFound:
await ctx.send(f"Hubo un error cargando el modulo {modulo}")
print(f"Hubo un error cargando el modulo {modulo}")
else:
pass
@bot.command(name="unload", hidden=True)
async def unload(ctx, modulo):
if ctx.author.id == 439470338150236162:
try:
bot.unload_extension(f"cogs.{modulo}")
await ctx.send(f"Módulo {modulo} descargado correctamente!")
print(f"Módulo {modulo} descargado correctamente!")
except discord.ext.commands.errors.ExtensionNotFound:
await ctx.send(f"Hubo un error descargando el modulo {modulo}")
print(f"Hubo un error descargando el modulo {modulo}")
else:
pass
@bot.command(name="reload", hidden=True)
async def reload(ctx, modulo):
if ctx.author.id == 439470338150236162:
try:
bot.reload_extension(f"cogs.{modulo}")
await ctx.send(f"Módulo {modulo} recargado correctamente!")
print(f"Módulo {modulo} recargado correctamente!")
except discord.ext.commands.errors.ExtensionNotFound:
await ctx.send(f"Hubo un error recargando el modulo {modulo}")
print(f"Hubo un error recargando el modulo {modulo}")
else:
pass
@bot.command(name="cogadd", hidden=True, aliases=["cogenable"])
async def cogadd(ctx, modulo):
with open("cogs.yaml", "r") as f:
cogList = yaml.safe_load(f)
if ctx.author.id == 439470338150236162:
cogList["cogs"][modulo] = {"enabled": True}
with open("cogs.yaml", "w") as f:
yaml.dump(cogList, f)
await ctx.send(f"Módulo {modulo} añadido correctamente!")
print(f"Módulo {modulo} añadido correctamente!")
try:
bot.load_extension(f"cogs.{modulo}")
except discord.ext.commands.errors.ExtensionNotFound:
print(f"{modulo} ya estaba cargado.")
else:
pass
@bot.command(name="cogdel", hidden=True, aliases=["cogdisable"])
async def cogdel(ctx, modulo):
with open("cogs.yaml", "r") as f:
cogList = yaml.safe_load(f)
if ctx.author.id == 439470338150236162:
cogList["cogs"][modulo] = {"enabled": False}
with open("cogs.yaml", "w") as f:
yaml.dump(cogList, f)
else:
pass
token = ""
bot.run(token)