Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Bot.command()
- async def py(ctx, kod=None):
- if not kod:
- await ctx.send('Usage: ;py {code}')
- return
- message = await ctx.send(embed=discord.Embed(title='Python executor', color=discord.Colour.green(),
- descriptio=f'```Waiting for response```'))
- cur_time = int(time.time())
- kod = kod.replace('```', ' ')
- kod = kod.replace('py', ' ')
- kod = kod.replace('```', ' ')
- po = {"cmd": 'python main.cpp', "src": kod}
- r = requests.post('http://coliru.stacked-crooked.com/compile', data=json.dumps(po))
- tim = int(time.time())
- res = r.text
- if len(res) == 0:
- res = 'No output'
- else:
- res = r.text[:1000]
- embed = discord.Embed(title='Python executor', color=discord.Colour.green(), description=f'```{res}```')
- embed.set_footer(text='Executed in {} seconds'.format(tim - cur_time))
- await message.edit(embed=embed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement