feat(sugoncredit): updated for slash commands
Some checks failed
Pylint / Pylint (3.11.2) (push) Failing after 9s
Some checks failed
Pylint / Pylint (3.11.2) (push) Failing after 9s
This commit is contained in:
parent
0aeb5ac25d
commit
8b144d3c38
1 changed files with 9 additions and 12 deletions
|
@ -1,19 +1,18 @@
|
||||||
import discord
|
import discord
|
||||||
from redbot.core import commands, bank, checks, data_manager
|
from redbot.core import commands, bank, data_manager
|
||||||
|
|
||||||
class SugonCredit(commands.Cog):
|
class SugonCredit(commands.Cog):
|
||||||
"""Implements a way for moderators to give out social-credit like points, dubbed 'sugoncredits' by the community."""
|
"""Implements a way for moderators to give out social-credit like points, dubbed 'sugoncredits' by the community."""
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
@commands.group(autohelp=True, aliases=["sugoncredit"])
|
@commands.hybrid_group(autohelp=True, aliases=["sugoncredit"])
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def credit(self, ctx):
|
async def credit(self, ctx: commands.Context):
|
||||||
"""Simple points system."""
|
"""Simple points system."""
|
||||||
|
|
||||||
@credit.command()
|
@credit.command()
|
||||||
@commands.guild_only()
|
async def balance(self, ctx: commands.Context, user: discord.Member = None):
|
||||||
async def balance(self, ctx, user: discord.Member = None):
|
|
||||||
"""Checks an account's balance."""
|
"""Checks an account's balance."""
|
||||||
bank_name = await bank.get_bank_name(ctx.guild)
|
bank_name = await bank.get_bank_name(ctx.guild)
|
||||||
currency_name = await bank.get_currency_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)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@credit.command()
|
@credit.command()
|
||||||
@commands.guild_only()
|
|
||||||
@commands.mod()
|
@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."""
|
"""Adds credits to an account."""
|
||||||
try:
|
try:
|
||||||
val = int(amount)
|
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!")
|
await ctx.send(content=f"You are attempting to set {target.mention}'s balance to below 0. Please try again!")
|
||||||
return
|
return
|
||||||
elif ctx.guild.id == 204965774618656769:
|
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 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}!")
|
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:
|
if amount == 1 or amount == -1:
|
||||||
|
@ -71,9 +69,8 @@ class SugonCredit(commands.Cog):
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@credit.command()
|
@credit.command()
|
||||||
@commands.guild_only()
|
|
||||||
@commands.mod()
|
@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."""
|
"""Removes credits from an account."""
|
||||||
try:
|
try:
|
||||||
val = int(amount)
|
val = int(amount)
|
||||||
|
@ -92,7 +89,7 @@ class SugonCredit(commands.Cog):
|
||||||
return
|
return
|
||||||
elif ctx.guild.id == 204965774618656769:
|
elif ctx.guild.id == 204965774618656769:
|
||||||
await bank.withdraw_credits(target, amount=amount)
|
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!")
|
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:
|
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)
|
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:
|
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}.")
|
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 ctx.send(embed=embed)
|
||||||
await bank.withdraw_credits(target, amount=val)
|
await bank.withdraw_credits(target, amount=val)
|
||||||
|
|
Loading…
Reference in a new issue