From 8b144d3c38b3c97ed4fed4fae5ee0d0f00da98f9 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Sat, 23 Sep 2023 11:11:50 -0400 Subject: [PATCH] feat(sugoncredit): updated for slash commands --- sugoncredit/sugoncredit.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sugoncredit/sugoncredit.py b/sugoncredit/sugoncredit.py index 902ab2a..43c264c 100644 --- a/sugoncredit/sugoncredit.py +++ b/sugoncredit/sugoncredit.py @@ -1,19 +1,18 @@ import discord -from redbot.core import commands, bank, checks, data_manager +from redbot.core import commands, bank, data_manager class SugonCredit(commands.Cog): """Implements a way for moderators to give out social-credit like points, dubbed 'sugoncredits' by the community.""" def __init__(self, bot): self.bot = bot - @commands.group(autohelp=True, aliases=["sugoncredit"]) + @commands.hybrid_group(autohelp=True, aliases=["sugoncredit"]) @commands.guild_only() - async def credit(self, ctx): + async def credit(self, ctx: commands.Context): """Simple points system.""" @credit.command() - @commands.guild_only() - async def balance(self, ctx, user: discord.Member = None): + async def balance(self, ctx: commands.Context, user: discord.Member = None): """Checks an account's balance.""" bank_name = await bank.get_bank_name(ctx.guild) currency_name = await bank.get_currency_name(ctx.guild) @@ -31,9 +30,8 @@ class SugonCredit(commands.Cog): await ctx.send(embed=embed) @credit.command() - @commands.guild_only() @commands.mod() - async def add(self, ctx, target: discord.Member, amount: int): + async def add(self, ctx: commands.Context, target: discord.Member, amount: int): """Adds credits to an account.""" try: val = int(amount) @@ -56,7 +54,7 @@ class SugonCredit(commands.Cog): await ctx.send(content=f"You are attempting to set {target.mention}'s balance to below 0. Please try again!") return elif ctx.guild.id == 204965774618656769: - logging_channel = self.bot.get_channel(1082495815878189076) + logging_channel: discord.TextChannel = self.bot.get_channel(1082495815878189076) await bank.deposit_credits(target, amount=amount) await ctx.send(content=f"{target.mention} now has {output_amount} more SugonCredit, with a total of {output_new_bal}!") if amount == 1 or amount == -1: @@ -71,9 +69,8 @@ class SugonCredit(commands.Cog): await ctx.send(embed=embed) @credit.command() - @commands.guild_only() @commands.mod() - async def remove(self, ctx, target: discord.Member, amount: int): + async def remove(self, ctx: commands.Context, target: discord.Member, amount: int): """Removes credits from an account.""" try: val = int(amount) @@ -92,7 +89,7 @@ class SugonCredit(commands.Cog): return elif ctx.guild.id == 204965774618656769: await bank.withdraw_credits(target, amount=amount) - logging_channel = self.bot.get_channel(1082495815878189076) + logging_channel: discord.TextChannel = self.bot.get_channel(1082495815878189076) await ctx.send(content=f"{target.mention} now has {output_amount} less SugonCredit, with a total of {output_new_bal}!\nIf this is a punishment, do better Galaxy Player! Re-education mods will be sent to your DM's if your SugonCredit drops to a substantially low amount!") if amount == 1 or amount == -1: await target.send(content=f"__MESSAGE FROM THE MINISTRY OF THE MEGA BASE__\n\n(我们的) {output_amount} SugonCredit has been taken from your account. Citizen, do not continue to preform bad actions! Glory to the Galaxy Communist Party!", file=image) @@ -103,4 +100,4 @@ class SugonCredit(commands.Cog): elif ctx.guild.id != 204965774618656769: embed=discord.Embed(title=f"{bank_name} - Remove", color=await self.bot.get_embed_color(None), description=f"{target.mention}'s {currency_name} balance has been decreased by {output_amount}.\nCurrent balance is {output_new_bal}.") await ctx.send(embed=embed) - await bank.withdraw_credits(target, amount=val) \ No newline at end of file + await bank.withdraw_credits(target, amount=val)