Include source command

This commit is contained in:
Dan Hess 2021-04-24 15:41:55 -08:00
parent 0c8dfa162b
commit 1acb507e27
1 changed files with 21 additions and 0 deletions

View File

@ -6,6 +6,8 @@ import utils
import random
import re
import calendar
import inspect
import io
import pendulum
import datetime
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)
@utils.can_run(send_messages=True)
async def joke(self, ctx):