-
Notifications
You must be signed in to change notification settings - Fork 1
/
execute.py
30 lines (25 loc) · 988 Bytes
/
execute.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
from nextcord import Message
from nextcord.ext.commands import Bot, Cog, Context, command
class ExecuteCog(Cog):
SUPERUSER = 229732075203330049
def __init__(self, bot: Bot):
self.bot = bot
@command()
async def execute(self, ctx: Context, *, message: str):
if ctx.message.author.id == self.SUPERUSER:
try:
result = eval(message.replace("```", ""))
await ctx.send(result)
except Exception as e:
await ctx.send(str(e))
raise e from e
@Cog.listener()
async def on_message_edit(self, before: Message, after: Message):
if after.content.startswith(self.bot.command_prefix + self.execute.name):
context = await self.bot.get_context(after)
await self.execute(
context,
message=after.content[
len(self.bot.command_prefix + self.execute.name) + 1 :
],
)