Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Commit

Permalink
Fixed server-list
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackstonecoden committed May 10, 2024
1 parent c1d3ace commit 555c6dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#THIS IS A SETUP FILE. RUN IT ONLY ONCE AND CONFIGURE THE .ENV FIRST. IT WILL SETUP THE DATABASE
admin_user = 12345 #Enter user ID of the user who should get admin perms (can be changed later with bot commands)
admin_user = 12345 #Enter user ID of the user who should get admin perms (can be changed later with bot commands)

# The name of the tables. Recommended to not change. If you wan't to change it, change it in config.json too
database = "server_list"
Expand Down
7 changes: 4 additions & 3 deletions src/cogs/commands/admin_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ async def remove_message(self, interaction: discord.Interaction, message: discor
@app_commands.guilds(admin_guild)
@app_commands.default_permissions(manage_messages=True)
@app_commands.describe(amount="Specify how many servers should be displayed")
@app_commands.choices(amount=[app_commands.Choice(name="10", value="10"), app_commands.Choice(name="20", value="20"), app_commands.Choice(name="50", value="50")])
@app_commands.choices(amount=[app_commands.Choice(name="50", value="50"), app_commands.Choice(name="100", value="100"), app_commands.Choice(name="200", value="200")])
async def server_list(self, interaction: discord.Interaction, amount: app_commands.Choice[str] = None):
L = 10 #Length
permission_level = get_user_permission_level(interaction.user.id)
Expand All @@ -314,10 +314,11 @@ async def server_list(self, interaction: discord.Interaction, amount: app_comman
return
if permission_level >= 4:
if amount is None:
server_amount = 10
guilds = sorted(self.client.guilds, key=lambda x: x.member_count, reverse=True)
else:
server_amount = int(amount.value)
guilds = sorted(self.client.guilds, key=lambda x: x.member_count, reverse=True)[:server_amount]
guilds = sorted(self.client.guilds, key=lambda x: x.member_count, reverse=True)[:server_amount]

server_count = len(self.client.guilds)

formatted_list = []
Expand Down
39 changes: 19 additions & 20 deletions src/cogs/global_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,7 @@ def __init__(self, client: commands.Bot):
async def on_message(self, message):
if message.author.bot:
return

permission_level = get_user_permission_level(message.author.id)
if permission_level is None or permission_level <= 15:
reason_block = None
if filter_text(message.content):
reason_block = block_reason["filter_text"]
if block_swear(message.content):
reason_block = block_reason["filter_swear"]
if block_links(message.content):
reason_block = block_reason["filter_link"]
if reason_block != None:
dm_channel = await message.author.create_dm()
embed = discord.Embed(title="Message blocked", description=f"Your message has been blocked by the Global Chat.", color=int(color["red_color"], 16), timestamp=embed_timestamp)
embed.add_field(name="Block reason", value=f"`{reason_block}`")
embed.set_footer(text=f"{bot_name}", icon_url=f"{bot_logo_url}")
await dm_channel.send(embed=embed)
await message.delete()
return


if get_globalchat(message.guild.id, message.channel.id):
if is_user_banned(message.author.id):
ban_reason = get_ban_reason(message.author.id)
Expand All @@ -178,8 +160,25 @@ async def on_message(self, message):
await dm_channel.send(embed=embed, view=BanButtons())
await message.delete()
return

permission_level = get_user_permission_level(message.author.id)
if permission_level is None or permission_level <= 15:
reason_block = None
if filter_text(message.content):
reason_block = block_reason["filter_text"]
if block_swear(message.content):
reason_block = block_reason["filter_swear"]
if block_links(message.content):
reason_block = block_reason["filter_link"]
if reason_block != None:
dm_channel = await message.author.create_dm()
embed = discord.Embed(title="Message blocked", description=f"Your message has been blocked by the Global Chat.", color=int(color["red_color"], 16), timestamp=embed_timestamp)
embed.add_field(name="Block reason", value=f"`{reason_block}`")
embed.set_footer(text=f"{bot_name}", icon_url=f"{bot_logo_url}")
await dm_channel.send(embed=embed)
await message.delete()
return

if permission_level is None:
permission_level = 0
if read_settings_variable("chat_lock") == True and permission_level < 4:
Expand Down

0 comments on commit 555c6dc

Please sign in to comment.