Include source command
This commit is contained in:
parent
0c8dfa162b
commit
1acb507e27
21
cogs/misc.py
21
cogs/misc.py
|
@ -6,6 +6,8 @@ import utils
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import calendar
|
import calendar
|
||||||
|
import inspect
|
||||||
|
import io
|
||||||
import pendulum
|
import pendulum
|
||||||
import datetime
|
import datetime
|
||||||
import psutil
|
import psutil
|
||||||
|
@ -268,6 +270,25 @@ class Miscellaneous(commands.Cog):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
@utils.can_run(send_messages=True)
|
||||||
|
async def source(self, ctx, *, command: str = None):
|
||||||
|
"""Displays my full source code or for a specific command.
|
||||||
|
|
||||||
|
EXAMPLE: !source source
|
||||||
|
RESULTS: Shows the code for this command!
|
||||||
|
"""
|
||||||
|
if command is None:
|
||||||
|
return await ctx.send("https://github.com/Phxntxm/Bonfire")
|
||||||
|
|
||||||
|
obj = self.bot.get_command(command)
|
||||||
|
if obj is None:
|
||||||
|
return await ctx.send(f"Could not find command {command}")
|
||||||
|
|
||||||
|
src = io.StringIO(inspect.getsource(obj.callback.__code__))
|
||||||
|
|
||||||
|
await ctx.send(file=discord.File(src, filename=f"{command}.py"))
|
||||||
|
|
||||||
@commands.command(enabled=False)
|
@commands.command(enabled=False)
|
||||||
@utils.can_run(send_messages=True)
|
@utils.can_run(send_messages=True)
|
||||||
async def joke(self, ctx):
|
async def joke(self, ctx):
|
||||||
|
|
Loading…
Reference in a new issue