From afebf45490fb9c91d15107af266946f1f28e647e Mon Sep 17 00:00:00 2001 From: phixxy Date: Thu, 18 Jan 2024 14:57:49 -0800 Subject: [PATCH] moved moderate command do admin.py --- plugins/admin.py | 20 +++++++++++++++++++- sparkytron3000.py | 9 --------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 364f51a..4ef2b44 100644 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -3,8 +3,15 @@ import os import sys import subprocess +import asyncssh from discord.ext import commands +async def upload_sftp(local_filename, server_folder, server_filename): + remotepath = server_folder + server_filename + async with asyncssh.connect(os.getenv('ftp_server'), username=os.getenv('ftp_username'), password=os.getenv('ftp_password')) as conn: + async with conn.start_sftp_client() as sftp: + await sftp.put(local_filename, remotepath=remotepath) + @commands.command( description="Kill", help="Kills the bot in event of an emergency. Only special users can do this! Usage: !kill", @@ -48,7 +55,18 @@ async def update(ctx): else: await ctx.send("You don't have permission to do this.") +@commands.command( + description="Moderate", + help="This currently tool works by replacing the filename on the ftp server with a black image. The description will remain the same and may need to be altered.", + brief="Moderation Tools" + ) +async def moderate(ctx, filename): + await upload_sftp("blank_image.png", (os.getenv('ftp_public_html') + 'ai-images/'), filename) + output = "Image " + filename + " replaced" + await ctx.send(output) + async def setup(bot): bot.add_command(update) bot.add_command(reset) - bot.add_command(kill) \ No newline at end of file + bot.add_command(kill) + bot.add_command(moderate) \ No newline at end of file diff --git a/sparkytron3000.py b/sparkytron3000.py index 2a58607..d0ed9d6 100644 --- a/sparkytron3000.py +++ b/sparkytron3000.py @@ -35,15 +35,6 @@ intents = discord.Intents.default() intents.message_content = True bot = commands.Bot(command_prefix='!', intents=intents) #discord setup END -@bot.command( - description="Moderate", - help="This currently tool works by replacing the filename on the ftp server with a black image. The description will remain the same and may need to be altered.", - brief="Moderation Tools" - ) -async def moderate(ctx, filename): - await upload_sftp("blank_image.png", (os.getenv('ftp_public_html') + 'ai-images/'), filename) - output = "Image " + filename + " replaced" - await ctx.send(output) async def upload_sftp(local_filename, server_folder, server_filename): remotepath = server_folder + server_filename