Skip to content

Commit

Permalink
improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
BadPingHere committed Dec 18, 2024
1 parent ea734b7 commit df0f56b
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 120 deletions.
2 changes: 1 addition & 1 deletion cogs/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async def autocomplete_remove(self, interaction: discord.Interaction, current: s
@app_commands.command(description="Add a guild to detect.")
@app_commands.describe(
channel='Channel to set',
guild_prefix='Prefix of the guild to track Ex: SEQ, ICo.',
guild_prefix='Prefix of the guild to track Ex: SEQ, ICo. (Case Sensitive)',
role='Role to be pinged (optional)',
interval='The cooldown on the pings in minutes (optional)',
)
Expand Down
53 changes: 26 additions & 27 deletions cogs/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ async def activityPlaytime(self, interaction: discord.Interaction, name: str):
cursor = conn.cursor()

if len(name) <= 4:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
else:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()

if not result:
Expand Down Expand Up @@ -113,16 +113,16 @@ async def activityXP(self, interaction: discord.Interaction, name: str):
cursor = conn.cursor()

if len(name) <= 4:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
else:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()

if not result:
Expand Down Expand Up @@ -152,16 +152,16 @@ async def activityTerritories(self, interaction: discord.Interaction, name: str)
cursor = conn.cursor()

if len(name) <= 4:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
else:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()

if not result:
Expand Down Expand Up @@ -190,16 +190,16 @@ async def activityWars(self, interaction: discord.Interaction, name: str):
cursor = conn.cursor()

if len(name) <= 4:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
else:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()

if not result:
Expand Down Expand Up @@ -227,16 +227,16 @@ async def activityTotal_members(self, interaction: discord.Interaction, name: st
cursor = conn.cursor()

if len(name) <= 4:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
else:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()

if not result:
Expand Down Expand Up @@ -265,16 +265,16 @@ async def activityOnline_members(self, interaction: discord.Interaction, name: s
cursor = conn.cursor()

if len(name) <= 4:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
else:
cursor.execute("SELECT uuid FROM guilds WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ?", (name,))
cursor.execute("SELECT uuid FROM guilds WHERE prefix = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()

if not result:
Expand Down Expand Up @@ -354,7 +354,6 @@ async def leaderboardXP(self, interaction: discord.Interaction):
else:
await interaction.followup.send("No data available.")

# This works, but the server im using to host this bot takes way too long to perform this. So uncomment if you want.
@leaderboardCommands.command(name="playtime", description="Shows a leaderboard of the top 10 guild's playtime percentage.")
async def leaderboardPlaytime(self, interaction: discord.Interaction):
logger.info(f"Command /guild leaderboard playtime was ran in server {interaction.guild_id} by user {interaction.user.name}({interaction.user.id}).")
Expand All @@ -372,7 +371,7 @@ async def leaderboardPlaytime(self, interaction: discord.Interaction):
await interaction.followup.send("No data available.")

@app_commands.command(description="Shows you to get a quick overview of a guild, like level, online members, etc.")
@app_commands.describe(name='Prefix or Name of the guild search Ex: TAq, Calvish.',)
@app_commands.describe(name='Prefix or Name of the guild search Ex: TAq, Calvish. (Case Sensitive)',)
async def overview(self, interaction: discord.Interaction, name: str):
logger.info(f"Command /guild overview was ran in server {interaction.guild_id} by user {interaction.user.name}({interaction.user.id}). Parameter guild is: {name}.")
current_time = time.time()
Expand All @@ -393,7 +392,7 @@ async def overview(self, interaction: discord.Interaction, name: str):
await interaction.response.send_message(f"'{name}' is an unknown prefix or guild name.", ephemeral=True)

@app_commands.command(description="Shows and sorts the player inactivity of a selected guild")
@app_commands.describe(name='Prefix or Name of the guild search Ex: TAq, Calvish.',)
@app_commands.describe(name='Prefix or Name of the guild search Ex: TAq, Calvish. (Case Sensitive)',)
async def inactivity(self, interaction: discord.Interaction, name: str):
logger.info(f"Command /guild inactivity was ran in server {interaction.guild_id} by user {interaction.user.name}({interaction.user.id}). Parameter guild is: {name}.")
current_time = time.time()
Expand Down
2 changes: 1 addition & 1 deletion cogs/hq.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, bot):
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
@app_commands.command(description="Outputs the top hq locations.")
@app_commands.describe(
guild='Prefix of the guild Ex: TAq, ICo.',
guild='Prefix of the guild Ex: TAq, ICo. (Case Sensitive)',
)
async def hq(self, interaction: discord.Interaction, guild: Optional[str]):
logger.info(f"Command /hq was ran in server {interaction.guild_id} by user {interaction.user.name}({interaction.user.id}). Parameter guild is: {guild}.")
Expand Down
10 changes: 5 additions & 5 deletions cogs/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ async def activityPlaytime(self, interaction: discord.Interaction, name: str):
conn = sqlite3.connect('database/guild_activity.db')
cursor = conn.cursor()

cursor.execute("SELECT uuid FROM members WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM members WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM members WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM members WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()

if not result:
Expand All @@ -50,7 +50,7 @@ async def activityPlaytime(self, interaction: discord.Interaction, name: str):

@activityCommands.command(name="xp", description="Shows the graph displaying the average amount of xp gain every day over the past two weeks.")
@app_commands.describe(name='Username of the player search Ex: BadPingHere, Salted.',)
async def activityPlaytime(self, interaction: discord.Interaction, name: str):
async def activityXP(self, interaction: discord.Interaction, name: str):
logger.info(f"Command /guild activity playtime was ran in server {interaction.guild_id} by user {interaction.user.name}({interaction.user.id}). Parameter guild is: {name}.")
current_time = time.time()
if int(current_time - self.guildLookupCooldown) <= 10:
Expand All @@ -61,10 +61,10 @@ async def activityPlaytime(self, interaction: discord.Interaction, name: str):
conn = sqlite3.connect('database/guild_activity.db')
cursor = conn.cursor()

cursor.execute("SELECT uuid FROM members WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM members WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()
if not result:
cursor.execute("SELECT uuid FROM members WHERE name = ?", (name,))
cursor.execute("SELECT uuid FROM members WHERE name = ? COLLATE NOCASE", (name,))
result = cursor.fetchone()

if not result:
Expand Down
2 changes: 1 addition & 1 deletion dernal.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
logger.addHandler(handler)

intents = discord.Intents.default()
bot = commands.Bot(command_prefix=None, intents=intents)
bot = commands.Bot(command_prefix=commands.when_mentioned, intents=intents)

def checkUpdates(localVersionFile='version.json'):
try:
Expand Down
Loading

0 comments on commit df0f56b

Please sign in to comment.