From ce0eda109a7c6912f974ec3280d62bb2051bb47d Mon Sep 17 00:00:00 2001 From: Wafelack Date: Sun, 20 Sep 2020 11:07:33 +0200 Subject: [PATCH] Adding wastebasket to del output and permise to put ```rs or ```rust where the fuck you want --- bot.py | 15 +++++++++++++-- play.py | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 9592082..7175c97 100644 --- a/bot.py +++ b/bot.py @@ -10,6 +10,14 @@ PREFIX = '!' WAFEID = 723862906755743804 +async def delout(message, user): + def check(reaction, user): + return str(reaction.emoji) == "🗑" and reaction.count > 1 and user == user and reaction.message.id == message.id + + reaction, user = await client.wait_for('reaction_add', check=check) + if check(reaction, user): + await message.delete() + @client.event async def on_ready(): @@ -29,11 +37,14 @@ async def on_message(message): splited = message.content.split('\n') stderr, stdout = play(splited) if stdout == "": - await message.channel.send(f"Standard error : ```" + stderr.replace('`', '\'') + "```\n```No standard " + msg = await message.channel.send(f"Standard error : ```" + stderr.replace('`', '\'') + "```\n```No standard " "output !```") else: - await message.channel.send( + msg = await message.channel.send( f"Standard error : ```" + stderr.replace('`', '\'') + f"```\nStandard output : ```{stdout}```") + + await msg.add_reaction("🗑") + client.loop.create_task(delout(msg, message.author)) return if message.content == PREFIX + "make_me_rustacean": await message.author.add_roles(message.author.guild.get_role(743864011334090762)) diff --git a/play.py b/play.py index c9b3c54..5298cdb 100644 --- a/play.py +++ b/play.py @@ -5,7 +5,7 @@ def play(code): file = open('code.rs', 'w') for i in range(1, len(code)): - file.write(code[i].replace('`', '')) + file.write(code[i].replace('```rs', '').replace('```rust', '').replace('`', '')) file.close() bfile = open('code.rs', 'rb')