Spaces:
Sleeping
Sleeping
Rifat Azad commited on
Commit ·
fac4b6b
1
Parent(s): 55abc6c
update 1.2.3
Browse files- pydvpl_bot.py +38 -5
pydvpl_bot.py
CHANGED
|
@@ -8,6 +8,7 @@ from dotenv import load_dotenv
|
|
| 8 |
from discord.ext import commands, tasks
|
| 9 |
from pydvpl.dvpl import compress_dvpl, decompress_dvpl, __LZ4_VERSION__
|
| 10 |
import pydvpl.version
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
# ENV_LOADER ------------------------------------------------------ START
|
|
@@ -22,7 +23,7 @@ load_dotenv()
|
|
| 22 |
# DEFINES ------------------------------------------------------ START
|
| 23 |
|
| 24 |
|
| 25 |
-
BOT_VERSION = '1.2.
|
| 26 |
|
| 27 |
AUTHORIZED_USER_ID = os.getenv('AUTHORIZED_ID')
|
| 28 |
|
|
@@ -301,7 +302,7 @@ async def help(ctx):
|
|
| 301 |
embed.add_field(name="Dvpl Commands:", value="`compress` - Compresses files.\n`decompress` - Decompresses files.", inline=False)
|
| 302 |
embed.add_field(name="User Utility Commands:", value="`ping` - Checks the bot's latency.\n`invite` - Get the bot's invite link.\n`uptime` - Displays the bot's uptime.", inline=False)
|
| 303 |
embed.add_field(name="Moderator Commands:", value="`kick` - Kick a member from the server.\n`ban` - Ban a member from the server.\n`timeout` - Timeout a member for a specified duration.", inline=False)
|
| 304 |
-
embed.add_field(name="Admin Utility Commands:", value="`stats` - Displays bot statistics.\n`list` - Lists server members.\n`say` - Make the bot say something.\n`announce` - Announces a message to a channel.\n`activity` - Sets bot activity status.\n`online` - Sets bot status to online.\n`dnd` - Sets bot status to Do Not Disturb.\n`offline` - Sets bot status to offline.\n`clean` - Cleans up bot's messages.", inline=False)
|
| 305 |
embed.add_field(name="Feedback Commands:", value="`feedback` - Sends feedback to bot developers. (usage: >>feedback issues/requests <message>)", inline=False)
|
| 306 |
|
| 307 |
# Customize based on your commands
|
|
@@ -790,6 +791,40 @@ async def list(ctx, list_type):
|
|
| 790 |
await ctx.send("Invalid list type. Please choose 'servers', 'issues', or 'requests'.")
|
| 791 |
|
| 792 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 793 |
# FUNCTION ------------------------------------------------------ SPLIT
|
| 794 |
|
| 795 |
|
|
@@ -912,9 +947,7 @@ async def timeout(ctx, member: discord.Member, duration: int, *, reason=None):
|
|
| 912 |
await ctx.send("You do not have permission to use this command.")
|
| 913 |
|
| 914 |
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
# UTILITY ADMIN_CMD ------------------------------------------------------ END
|
| 918 |
|
| 919 |
|
| 920 |
|
|
|
|
| 8 |
from discord.ext import commands, tasks
|
| 9 |
from pydvpl.dvpl import compress_dvpl, decompress_dvpl, __LZ4_VERSION__
|
| 10 |
import pydvpl.version
|
| 11 |
+
import subprocess
|
| 12 |
|
| 13 |
|
| 14 |
# ENV_LOADER ------------------------------------------------------ START
|
|
|
|
| 23 |
# DEFINES ------------------------------------------------------ START
|
| 24 |
|
| 25 |
|
| 26 |
+
BOT_VERSION = '1.2.3'
|
| 27 |
|
| 28 |
AUTHORIZED_USER_ID = os.getenv('AUTHORIZED_ID')
|
| 29 |
|
|
|
|
| 302 |
embed.add_field(name="Dvpl Commands:", value="`compress` - Compresses files.\n`decompress` - Decompresses files.", inline=False)
|
| 303 |
embed.add_field(name="User Utility Commands:", value="`ping` - Checks the bot's latency.\n`invite` - Get the bot's invite link.\n`uptime` - Displays the bot's uptime.", inline=False)
|
| 304 |
embed.add_field(name="Moderator Commands:", value="`kick` - Kick a member from the server.\n`ban` - Ban a member from the server.\n`timeout` - Timeout a member for a specified duration.", inline=False)
|
| 305 |
+
embed.add_field(name="Admin Utility Commands:", value="`stats` - Displays bot statistics.\n`list` - Lists server members.\n`say` - Make the bot say something.\n`announce` - Announces a message to a channel.\n`activity` - Sets bot activity status.\n`online` - Sets bot status to online.\n`dnd` - Sets bot status to Do Not Disturb.\n`offline` - Sets bot status to offline.\n`clean` - Cleans up bot's messages.\n`update` - Update a Python package using pip.", inline=False)
|
| 306 |
embed.add_field(name="Feedback Commands:", value="`feedback` - Sends feedback to bot developers. (usage: >>feedback issues/requests <message>)", inline=False)
|
| 307 |
|
| 308 |
# Customize based on your commands
|
|
|
|
| 791 |
await ctx.send("Invalid list type. Please choose 'servers', 'issues', or 'requests'.")
|
| 792 |
|
| 793 |
|
| 794 |
+
# FUNCTION ------------------------------------------------------ SPLIT
|
| 795 |
+
|
| 796 |
+
|
| 797 |
+
@bot.hybrid_command(help="Update a Python package using pip.")
|
| 798 |
+
async def update(ctx, pkg_name):
|
| 799 |
+
# Check if the author is authorized to use this command
|
| 800 |
+
if str(ctx.author.id) != AUTHORIZED_USER_ID:
|
| 801 |
+
await ctx.send("You are not authorized to use this command.")
|
| 802 |
+
return
|
| 803 |
+
|
| 804 |
+
try:
|
| 805 |
+
|
| 806 |
+
await ctx.send(f"Updating package `{pkg_name}`...")
|
| 807 |
+
|
| 808 |
+
# Run pip install command to upgrade the package
|
| 809 |
+
process = subprocess.Popen(['pip', 'install', pkg_name, '--upgrade'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 810 |
+
output, error = process.communicate()
|
| 811 |
+
|
| 812 |
+
if error:
|
| 813 |
+
await ctx.send(f"Failed to update package `{pkg_name}`. Error: {error.decode('utf-8')}")
|
| 814 |
+
else:
|
| 815 |
+
await ctx.send(f"Package `{pkg_name}` successfully updated.")
|
| 816 |
+
except Exception as e:
|
| 817 |
+
await ctx.send(f"An error occurred while updating package `{pkg_name}`: {e}")
|
| 818 |
+
|
| 819 |
+
|
| 820 |
+
|
| 821 |
+
|
| 822 |
+
# UTILITY ADMIN_CMD ------------------------------------------------------ END
|
| 823 |
+
|
| 824 |
+
|
| 825 |
+
# UTILITY MODERATOR_CMD ------------------------------------------------------ START
|
| 826 |
+
|
| 827 |
+
|
| 828 |
# FUNCTION ------------------------------------------------------ SPLIT
|
| 829 |
|
| 830 |
|
|
|
|
| 947 |
await ctx.send("You do not have permission to use this command.")
|
| 948 |
|
| 949 |
|
| 950 |
+
# UTILITY MODERATOR_CMD ------------------------------------------------------ END
|
|
|
|
|
|
|
| 951 |
|
| 952 |
|
| 953 |
|