Browse Source

fetchdata: add .fetchdata and make bot start send data files

main
Ave Ozkal 2 years ago
parent
commit
63e76c31bf
2 changed files with 15 additions and 5 deletions
  1. +7
    -4
      Robocop.py
  2. +8
    -1
      cogs/admin.py

+ 7
- 4
Robocop.py View File

@ -37,6 +37,9 @@ def get_prefix(bot, message):
return commands.when_mentioned_or(*prefixes)(bot, message)
wanted_jsons = ["data/restrictions.json",
"data/userlog.json"]
initial_extensions = ['cogs.common',
'cogs.admin',
'cogs.basic',
@ -58,6 +61,7 @@ bot = commands.Bot(command_prefix=get_prefix,
bot.log = log
bot.config = config
bot.script_name = script_name
bot.wanted_jsons = wanted_jsons
if __name__ == '__main__':
for extension in initial_extensions:
@ -83,7 +87,9 @@ async def on_ready():
log_channel = guild.get_channel(config.log_channel)
msg = f"{bot.user.name} has started! "\
f"{guild.name} has {guild.member_count} members!"
await log_channel.send(msg)
config_files = [discord.File(fpath) for fpath in wanted_jsons]
await log_channel.send(msg, files=config_files)
await bot.change_presence(activity=discord.Game(name=game_name))
@ -170,9 +176,6 @@ async def on_message(message):
if not os.path.exists("data"):
os.makedirs("data")
wanted_jsons = ["data/restrictions.json",
"data/userlog.json"]
for wanted_json in wanted_jsons:
if not os.path.exists(wanted_json):
with open(wanted_json, "w") as f:


+ 8
- 1
cogs/admin.py View File

@ -39,10 +39,17 @@ class Admin:
@commands.command()
async def fetchlog(self, ctx):
"""Returns log"""
await ctx.send("This is currently broken.")
await ctx.send("Here's the current log file:",
file=discord.File(f"{self.bot.script_name}.log"))
@commands.guild_only()
@commands.check(check_if_bot_manager)
@commands.command()
async def fetchdata(self, ctx):
"""Returns data files"""
config_files = [discord.File(fpath) for fpath in self.bot.wanted_jsons]
await ctx.send("Here you go:", files=config_files)
@commands.guild_only()
@commands.check(check_if_bot_manager)
@commands.command(name='eval')


Loading…
Cancel
Save