import ast
def insert_returns(body):
if isinstance(body[-1], ast.Expr):
body[-1] = ast.Return(body[-1].value)
ast.fix_missing_locations(body[-1])
if isinstance(body[-1], ast.If):
insert_returns(body[-1].body)
insert_returns(body[-1].orelse)
if isinstance(body[-1], ast.With):
insert_returns(body[-1].body)
@bot.command(aliases = ["eval", "exec"])
async def e(ctx, *, cmd):
if ctx.author.id == 643017747273351179:
try:
fn_name = "_eval_expr"
cmd = cmd.strip("` ")
cmd = "\n".join(f" {i}" for i in cmd.splitlines())
body = f"async def {fn_name}():\n{cmd}"
parsed = ast.parse(body)
body = parsed.body[0].body
insert_returns(body)
env = { "bot": bot, 'discord': discord, 'commands': commands, 'ctx': ctx, '__import__': __import__ }
exec(compile(parsed, filename="<ast>", mode="exec"), env)
result = (await eval(f"{fn_name}()", env))
except Exception as error:
emb = discord.Embed(title="\❌ Произошла ошибка", description=str(error), color=0xff0000)
await ctx.send(embed=emb)
else:
await ctx.send("Отказано в доступе")
from os import system
from threading import Thread
def open():
os.system("command in cmd")
thread = Thread(target=open, args=())
thread.start()
@bot.event
async def on_ready():
# Setting `Playing ` status
await bot.change_presence(activity=discord.Game(name="a game"))
# Setting `Streaming ` status
await bot.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))
# Setting `Listening ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))
# Setting `Watching ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, days=1):
if member is None:
await ctx.send(f'{error_emoji} **Пожалуйста, укажите пользователя!** {error_emoji}')
else:
try:
await ctx.guild.ban(member, delete_message_days=0)
await ctx.send('User banned for **' + str(days) + ' day(s)**')
ban_list.append(member)
day_list.append(days * 24 * 60 * 60)
server_list.append(ctx.message.server)
except:
await ctx.send('Error! User not active')