Skip to content

Commit

Permalink
refactor: autofix issues in 15 files
Browse files Browse the repository at this point in the history
Resolved issues in the following files with DeepSource Autofix:
1. bot/bot.py
2. cogs/dashboard.py
3. cogs/error_handler.py
4. cogs/help.py
5. cogs/misc.py
6. cogs/premium.py
7. cogs/verify.py
8. utils/constants.py
9. utils/utils.py
10. views/answer_button.py
11. views/dashboard_views.py
12. views/embed_creator.py
13. views/length_modal.py
14. views/role_select.py
15. views/verify_button.py
  • Loading branch information
deepsource-autofix[bot] authored Nov 17, 2023
1 parent 41d19f4 commit 96ab9c9
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 77 deletions.
3 changes: 1 addition & 2 deletions bot/bot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import nextcord
import json, asyncio
import os
from nextcord.ext import commands, tasks
from nextcord.ext import commands
from utils.utils import *
from utils.constants import TOKEN

Expand Down
2 changes: 1 addition & 1 deletion cogs/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Dashboard(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client

@nextcord.slash_command(name=f"dashboard", description=f"Configure the bot on the in-discord dashboard")
@nextcord.slash_command(name="dashboard", description="Configure the bot on the in-discord dashboard")
async def dashboard(self, interaction: Interaction):
await interaction.response.defer(with_message=True, ephemeral=True)
if not interaction.user.guild_permissions.administrator:
Expand Down
4 changes: 2 additions & 2 deletions cogs/error_handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import nextcord
from cooldowns import CallableOnCooldown
from nextcord.ext import commands, application_checks
from nextcord.ext import commands
from bot.bot import Bot
from nextcord.errors import Forbidden
from utils import *
Expand All @@ -16,7 +16,7 @@ async def on_application_command_error(self, interaction:nextcord.Interaction, e
if isinstance(error, CallableOnCooldown):
await interaction.send(f"That command is on cooldown. You can use it again <t:{int(error.retry_after) + round(int(time.time()))}:R>")
elif isinstance(error, Forbidden):
await interaction.send(f"I don't have permission to do that")
await interaction.send("I don't have permission to do that")
else:
raise error

Expand Down
6 changes: 3 additions & 3 deletions cogs/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class Help(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client

@nextcord.slash_command(name=f"help", description=f"Help command")
@nextcord.slash_command(name="help", description="Help command")
async def help(self, interaction: Interaction):
await interaction.response.defer()
embed = nextcord.Embed(title=(f"Help"), description=(f"""Below is a list of all commands you will need:"""), colour=COLOUR_MAIN)
embed.add_field(name=f"/dashboard", value=f"""Explanation: Manage the bot's settings
embed = nextcord.Embed(title=("Help"), description=("""Below is a list of all commands you will need:"""), colour=COLOUR_MAIN)
embed.add_field(name=f"/dashboard", value="""Explanation: Manage the bot's settings
Requires: Administrator
Usage: ``/dashboard``""")
embed.add_field(name=f"/verifymessage", value=f"""Explanation: Send a verification message to a channel
Expand Down
16 changes: 8 additions & 8 deletions cogs/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ async def botinfo(self, interaction: Interaction):
Privacy: [Privacy Policy]({PRIVACYLINK})""", colour=COLOUR_MAIN)
await msg.edit(content = " ", embed=embed, view=BotInfoLinkButton())

@nextcord.slash_command(name=f"privacy", description=f"Get the link to our privacy policy")
@nextcord.slash_command(name="privacy", description="Get the link to our privacy policy")
async def privacy(self, interaction:Interaction):
await interaction.send(content="", view=PrivacyPolicyButton())


@nextcord.slash_command(name=f"shardinfo", description=f"Get information on all shards")
@nextcord.slash_command(name="shardinfo", description="Get information on all shards")
@cooldowns.cooldown(1, 30, bucket=cooldowns.SlashBucket.author)
async def shardinfo(self, interaction:Interaction):
await interaction.response.defer()
Expand All @@ -44,16 +44,16 @@ async def shardinfo(self, interaction:Interaction):
description+=f"\n**Shard {shard+1}** has `{round(specshard.latency*100)}ms` latency with `{shard_servers} servers`"

if not interaction.guild:
await interaction.send(embed=nextcord.Embed(title=f"Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))
await interaction.send(embed=nextcord.Embed(title="Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))
else:
guild_shard = interaction.guild.shard_id
guildspecshard = self.client.get_shard(guild_shard)
guild_shard_servers = len([guild for guild in self.client.guilds if guild.shard_id == guild_shard])
await interaction.send(f"This server's shard is shard **{guild_shard+1}** with `{round(guildspecshard.latency*100)}ms` and `{guild_shard_servers} servers`", embed=nextcord.Embed(title=f"Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))
await interaction.send(f"This server's shard is shard **{guild_shard+1}** with `{round(guildspecshard.latency*100)}ms` and `{guild_shard_servers} servers`", embed=nextcord.Embed(title="Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))



@nextcord.slash_command(name=f"shardinfo", description=f"Get information on all shards")
@nextcord.slash_command(name="shardinfo", description="Get information on all shards")
@cooldowns.cooldown(1, 30, bucket=cooldowns.SlashBucket.author)
async def shardinfo(self, interaction:Interaction):
await interaction.response.defer()
Expand All @@ -64,15 +64,15 @@ async def shardinfo(self, interaction:Interaction):
description+=f"\n**Shard {shard+1}** has `{round(specshard.latency*100)}ms` latency with `{shard_servers} servers`"

if not interaction.guild:
await interaction.send(embed=nextcord.Embed(title=f"Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))
await interaction.send(embed=nextcord.Embed(title="Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))
else:
guild_shard = interaction.guild.shard_id
guildspecshard = self.client.get_shard(guild_shard)
guild_shard_servers = len([guild for guild in self.client.guilds if guild.shard_id == guild_shard])
await interaction.send(f"This server's shard is shard **{guild_shard+1}** with `{round(guildspecshard.latency*100)}ms` and `{guild_shard_servers} servers`", embed=nextcord.Embed(title=f"Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))
await interaction.send(f"This server's shard is shard **{guild_shard+1}** with `{round(guildspecshard.latency*100)}ms` and `{guild_shard_servers} servers`", embed=nextcord.Embed(title="Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))


@nextcord.slash_command(name=f"debug", description=f"Get information useful for debugging")
@nextcord.slash_command(name="debug", description="Get information useful for debugging")
@cooldowns.cooldown(1,10, bucket=cooldowns.SlashBucket.channel)
async def _debug(self, interaction:Interaction):
await interaction.response.defer()
Expand Down
42 changes: 21 additions & 21 deletions cogs/premium.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import nextcord
import pymysql
from nextcord.ext import commands, tasks
from nextcord.ext import commands
from nextcord import Interaction, SlashOption
from utils import check_premium, create_error_embed, create_warning_embed, create_success_embed, PREMIUMLINK, DBENDPOINT, DBUSER, DBPASS, DBNAME, COLOUR_MAIN

class Premium(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client

@nextcord.slash_command(name=f"manage-premium", description=f"Manage your premium membership", guild_ids=[1111387758028652657, 801744339343507457])
@nextcord.slash_command(name="manage-premium", description="Manage your premium membership", guild_ids=[1111387758028652657, 801744339343507457])
async def manage_premium(self, interaction: Interaction):
pass

@manage_premium.subcommand(name=f"add-server", description=f"Add a server to your premium subscription")
@manage_premium.subcommand(name="add-server", description="Add a server to your premium subscription")
async def manage_premium_add_server(self, interaction: Interaction,
guildid: str = SlashOption(
name=f"guild",
description=f"The ID of the guild to add to premium. Use /debug in your server to get this.",
name="guild",
description="The ID of the guild to add to premium. Use /debug in your server to get this.",
required = True
)):
await interaction.response.defer()
if not check_premium(self, False, True, interaction.user.id):
await interaction.send(embed=create_error_embed(title=f"No premium subscription", description=f"You are not currently subscribed to any of our premium subscriptions. To purchase premium please follow [this link]({PREMIUMLINK})\n\n\nPlease Note: If you recently subscribed to premium it may take up to 30 minutes to register your subscription. If you are still unable to use this command in 30 minutes, please create a ticket in <#1111392014529990656>"))
await interaction.send(embed=create_error_embed(title="No premium subscription", description=f"You are not currently subscribed to any of our premium subscriptions. To purchase premium please follow [this link]({PREMIUMLINK})\n\n\nPlease Note: If you recently subscribed to premium it may take up to 30 minutes to register your subscription. If you are still unable to use this command in 30 minutes, please create a ticket in <#1111392014529990656>"))
return

if check_premium(self, True, False, guildid):
await interaction.send(embed=create_warning_embed(title=f"Guild already added", description=f"This guild is already added to your premium subscription."))
await interaction.send(embed=create_warning_embed(title="Guild already added", description="This guild is already added to your premium subscription."))
return

conn = pymysql.connect(host=DBENDPOINT, port=3306, user=DBUSER, password=DBPASS, db=DBNAME)
Expand All @@ -41,38 +41,38 @@ async def manage_premium_add_server(self, interaction: Interaction,
servers_used = len(data) if data else 0

if servers_available <= servers_used:
await interaction.send(embed=create_warning_embed(title=f"Max Servers Reached", description=f"You have reached the limit of premium servers that your current premium subscription allows for (``{servers_available}``). To increase this limit, upgrade your premium subscription via [this link]({PREMIUMLINK})"))
await interaction.send(embed=create_warning_embed(title="Max Servers Reached", description=f"You have reached the limit of premium servers that your current premium subscription allows for (``{servers_available}``). To increase this limit, upgrade your premium subscription via [this link]({PREMIUMLINK})"))
return

try:
guild = self.client.get_guild(int(guildid))
except:
await interaction.send(embed=create_error_embed(title=f"Invalid guild ID", description=f"You have given an invalid guild ID. Please use the `/debug` command in the guild you want to add premium to to get the correct guild ID."))
await interaction.send(embed=create_error_embed(title="Invalid guild ID", description="You have given an invalid guild ID. Please use the `/debug` command in the guild you want to add premium to to get the correct guild ID."))
return

if guild is None:
await interaction.send(embed=create_error_embed(title=f"Invalid guild ID", description=f"You have given an invalid guild ID. Please use the `/debug` command in the guild you want to add premium to to get the correct guild ID."))
await interaction.send(embed=create_error_embed(title="Invalid guild ID", description="You have given an invalid guild ID. Please use the `/debug` command in the guild you want to add premium to to get the correct guild ID."))
return

cur.execute("INSERT INTO sv_premium_guilds (user_id, guild_id) VALUES (%s, %s)", (str(interaction.user.id), guildid))
conn.commit()

await interaction.send(embed=create_success_embed(title=f"Premium server added", description=f"You have succesfully added `{guild.name} ({guild.id})` to your premium subscription."))
await interaction.send(embed=create_success_embed(title="Premium server added", description=f"You have succesfully added `{guild.name} ({guild.id})` to your premium subscription."))

@manage_premium.subcommand(name=f"remove-server", description=f"Remove a server from your premium subscription")
@manage_premium.subcommand(name="remove-server", description="Remove a server from your premium subscription")
async def manage_premium_remove_server(self, interaction: Interaction,
guildid: str = SlashOption(
name=f"guild",
description=f"The ID of the guild to remove from premium. Use /debug in your server to get this.",
name="guild",
description="The ID of the guild to remove from premium. Use /debug in your server to get this.",
required = True
)):
await interaction.response.defer()
if not check_premium(self, False, True, interaction.user.id):
await interaction.send(embed=create_error_embed(title=f"No premium subscription", description=f"You are not currently subscribed to any of our premium subscriptions. To purchase premium please follow [this link]({PREMIUMLINK})\n\n\nPlease Note: If you recently subscribed to premium it may take up to 30 minutes to register your subscription. If you are still unable to use this command in 30 minutes, please create a ticket in <#1111392014529990656>"))
await interaction.send(embed=create_error_embed(title="No premium subscription", description=f"You are not currently subscribed to any of our premium subscriptions. To purchase premium please follow [this link]({PREMIUMLINK})\n\n\nPlease Note: If you recently subscribed to premium it may take up to 30 minutes to register your subscription. If you are still unable to use this command in 30 minutes, please create a ticket in <#1111392014529990656>"))
return

if not check_premium(self, True, False, guildid):
await interaction.send(embed=create_warning_embed(title=f"Guild not added", description=f"This guild is not currently added to your premium subscription."))
await interaction.send(embed=create_warning_embed(title="Guild not added", description="This guild is not currently added to your premium subscription."))
return

try:
Expand All @@ -88,13 +88,13 @@ async def manage_premium_remove_server(self, interaction: Interaction,
cur.execute("DELETE FROM sv_premium_guilds WHERE user_id=%s AND guild_id=%s", (str(interaction.user.id), guildid))
conn.commit()

await interaction.send(embed=create_success_embed(title=f"Premium server removed", description=f"You have succesfully removed `{guild.name if not guild == 'Unknown' else 'Unknown'} ({guildid})` from your premium subscription."))
await interaction.send(embed=create_success_embed(title="Premium server removed", description=f"You have succesfully removed `{guild.name if not guild == 'Unknown' else 'Unknown'} ({guildid})` from your premium subscription."))

@manage_premium.subcommand(name=f"view", description=f"View your current premium subscription")
@manage_premium.subcommand(name="view", description="View your current premium subscription")
async def manage_premium_view(self, interaction: Interaction):
await interaction.response.defer()
if not check_premium(self, False, True, interaction.user.id):
await interaction.send(embed=create_error_embed(title=f"No premium subscription", description=f"You are not currently subscribed to any of our premium subscriptions. To purchase premium please follow [this link]({PREMIUMLINK})\n\n\nPlease Note: If you recently subscribed to premium it may take up to 30 minutes to register your subscription. If you are still unable to use this command in 30 minutes, please create a ticket in <#1111392014529990656>"))
await interaction.send(embed=create_error_embed(title="No premium subscription", description=f"You are not currently subscribed to any of our premium subscriptions. To purchase premium please follow [this link]({PREMIUMLINK})\n\n\nPlease Note: If you recently subscribed to premium it may take up to 30 minutes to register your subscription. If you are still unable to use this command in 30 minutes, please create a ticket in <#1111392014529990656>"))
return

conn = pymysql.connect(host=DBENDPOINT, port=3306, user=DBUSER, password=DBPASS, db=DBNAME)
Expand All @@ -118,7 +118,7 @@ async def manage_premium_view(self, interaction: Interaction):
for role in interaction.user.roles:
if role in premium_roles:
user_premium_role = role
embed=nextcord.Embed(title=f"Your premium subscription", description=f"Subscription: **{user_premium_role.name}**\nServers (Used Servers/Available Servers): **{len(servers_used)}/{servers_available}**", colour=COLOUR_MAIN)
embed=nextcord.Embed(title="Your premium subscription", description=f"Subscription: **{user_premium_role.name}**\nServers (Used Servers/Available Servers): **{len(servers_used)}/{servers_available}**", colour=COLOUR_MAIN)
servers_using = ""

for serverid in servers_used:
Expand All @@ -127,7 +127,7 @@ async def manage_premium_view(self, interaction: Interaction):
servers_using += f"**{guild.name}** ({guild.id})\n"
except:
servers_using += f"**Unknown** ({serverid[1]})"
embed.add_field(name=f"Servers", value=f"{servers_using}")
embed.add_field(name="Servers", value=f"{servers_using}")
await interaction.send(embed=embed)


Expand Down
Loading

0 comments on commit 96ab9c9

Please sign in to comment.