1
Fork 0
mirror of https://github.com/RGBCube/VReplBot synced 2025-07-25 23:47:45 +00:00

Make it functional

This commit is contained in:
RGBCube 2023-01-30 20:20:29 +03:00
parent 9eb87f0c8d
commit 80ec2b9d9e
2 changed files with 8 additions and 5 deletions

View file

@ -32,11 +32,11 @@ class ReplBot(CommandsBot):
command_prefix = when_mentioned_or("&"),
strip_after_prefix = True,
case_insensitive = True,
status = Game("on play.minearchy.com"),
owner_ids = { 512640455834337290 },
status = Game("in the V playground"),
allowed_mentions = AllowedMentions.none(),
max_messages = 100,
intents = Intents(
guilds = True,
messages = True,
message_content = True,
),

View file

@ -28,17 +28,20 @@ class REPL(
async def eval(
self,
ctx: Context,
*,
code: Codeblock | None = commands.param(converter = codeblock_converter, default = None)
) -> None:
if code is None:
await ctx.reply("No code provided.")
return
with self.bot.session.post(
"https://vlang.io/play",
async with await self.bot.session.post(
"https://play.vlang.io/run",
data = { "code": code.content },
) as response:
text = await response.text()
await ctx.reply(
"```\n" + response.text.replace("`", "\u200B`\u200B") + "\n```"
"```\n" + text.replace("`", "\u200B`\u200B") + "\n```"
) # Zero-width space.