Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. @Bot.command()
  2. async def py(ctx, kod=None):
  3.     if not kod:
  4.         await ctx.send('Usage: ;py {code}')
  5.         return
  6.     message = await ctx.send(embed=discord.Embed(title='Python executor', color=discord.Colour.green(),
  7.                                                  descriptio=f'```Waiting for response```'))
  8.     cur_time = int(time.time())
  9.     kod = kod.replace('```', ' ')
  10.     kod = kod.replace('py', ' ')
  11.     kod = kod.replace('```', ' ')
  12.     po = {"cmd": 'python main.cpp', "src": kod}
  13.     r = requests.post('http://coliru.stacked-crooked.com/compile', data=json.dumps(po))
  14.     tim = int(time.time())
  15.     res = r.text
  16.     if len(res) == 0:
  17.         res = 'No output'
  18.     else:
  19.         res = r.text[:1000]
  20.     embed = discord.Embed(title='Python executor', color=discord.Colour.green(), description=f'```{res}```')
  21.     embed.set_footer(text='Executed in {} seconds'.format(tim - cur_time))
  22.  
  23.     await message.edit(embed=embed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement