feat(sugoncredit): updated for slash commands
Some checks failed
Pylint / Pylint (3.11.2) (push) Failing after 9s

This commit is contained in:
Seaswimmer 2023-09-23 11:11:50 -04:00
parent 0aeb5ac25d
commit 8b144d3c38
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -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)