Skip to content

Commit

Permalink
ClashKing v4
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicTheDev committed Feb 13, 2024
1 parent 3a76fca commit 79951de
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion commands/eval/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async def auto_refresh_options(self, ctx: disnake.ApplicationCommandInteraction,
blacklist_role_add: disnake.Role = None,
blacklist_role_remove: disnake.Role = None):
await ctx.response.defer()
if blacklist_role_add.id == blacklist_role_remove.id:
if blacklist_role_add == blacklist_role_remove and isinstance(blacklist_role_add, disnake.Role):
raise MessageException("Cannot both remove and add the same role to/from blacklist at the same time")

db_server = await self.bot.ck_client.get_server_settings(server_id=ctx.guild_id)
Expand Down
4 changes: 2 additions & 2 deletions commands/family/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ def capital_gold_raided(elem):

@register_button("familyoverview", parser="_:server")
async def family_overview(bot: CustomClient, server: disnake.Guild, embed_color: disnake.Color):
server = await bot.getch_guild(server.id)
season = bot.gen_season_date()
clan_tags = await bot.clan_db.distinct("tag", filter={"server": server.id})
basic_clans = await bot.basic_clan.find({"tag": {"$in": clan_tags}}).to_list(length=None)

owner = await server.getch_member(server.owner_id)
member_count = sum([c.get("members", 0) for c in basic_clans])
member_tags = [m.get("tag") for clan in basic_clans for m in clan.get("memberList", [])]
sixty_mins = pend.now(tz=pend.UTC).subtract(minutes=60)
Expand All @@ -245,7 +245,7 @@ async def family_overview(bot: CustomClient, server: disnake.Guild, embed_color:
f"- {len(basic_clans)} Clans, {member_count} Members\n"
f"- {last_online_sixty_mins} Online (last hour)\n"
f"- Created: {bot.timestamper(unix_time=int(server.created_at.timestamp())).text_date}\n"
f"- Owner: {server.owner.display_name}")
f"- Owner: {owner.display_name}")
first_embed = disnake.Embed(description=description_text, color=embed_color)
first_embed.set_author(name=f"{server.name} Overview", icon_url=get_guild_icon(server))

Expand Down
5 changes: 2 additions & 3 deletions commands/link/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from utility.search import search_results
from ..eval.utils import logic
from archived.commands.CommandsOlder.Utils.Player import to_do_embed
from utility.discord_utils import basic_embed_modal
from exceptions.CustomExceptions import MessageException, InvalidAPIToken, APITokenRequired
from discord import convert, autocomplete

Expand Down Expand Up @@ -153,7 +152,7 @@ async def unlink(self, ctx: disnake.ApplicationCommandInteraction,



@commands.slash_command(name="buttons", description="Create a message that has buttons for easy eval/link/refresh actions.")
'''@commands.slash_command(name="buttons", description="Create a message that has buttons for easy eval/link/refresh actions.")
async def buttons(self, ctx: disnake.ApplicationCommandInteraction, type=commands.Param(choices=["Link Button", "Refresh Button", "To-Do Button", "Roster Button"]), ping: disnake.User = None,
custom_embed = commands.Param(default="False", choices=["True", "False"]), embed_link: str = None):
Expand Down Expand Up @@ -258,7 +257,7 @@ async def buttons(self, ctx: disnake.ApplicationCommandInteraction, type=command
content = ping.mention
else:
content = ""
await ctx.send(content=content, embed=embed, components=[buttons])
await ctx.send(content=content, embed=embed, components=[buttons])'''



Expand Down
2 changes: 0 additions & 2 deletions discord/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ async def on_connect(self):
for count, shard in self.bot.shards.items():
await self.bot.change_presence(activity=disnake.CustomActivity(state="↻ Bot starting up", name="Custom Status"), shard_id=shard.id)



tags = await self.bot.clan_db.distinct("tag", filter={"server" : {"$in" : list(self.bot.OUR_GUILDS)}})
self.bot.clan_list = tags

Expand Down
6 changes: 5 additions & 1 deletion exceptions/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ async def on_slash_command_error(self, ctx: disnake.ApplicationCommandInteractio
embed = disnake.Embed(description="Not a valid reminder time, please use options from the autocomplete.", color=disnake.Color.red())
return await ctx.send(embed=embed)

if isinstance(error, PlayerNotInLegends):
embed = disnake.Embed(description=f"Player is not in legends.",
color=disnake.Color.red())
return await ctx.send(embed=embed)

if isinstance(error, ThingNotFound):
embed = disnake.Embed(description=f"{str(error)}", color=disnake.Color.red())
Expand Down Expand Up @@ -178,7 +182,7 @@ async def on_slash_command_error(self, ctx: disnake.ApplicationCommandInteractio
return await ctx.edit_original_message(components=[])

event_id = sentry_sdk.capture_exception(error)
embed = disnake.Embed(description=f"An internal error occurred. Please report to our [support server](https://discord.gg/clashking)", color=disnake.Color.red())
embed = disnake.Embed(description=f"An internal error occurred, it has been reported to the developer. You can follow updates & bug fixes in the [support server](https://discord.gg/clashking)", color=disnake.Color.red())

if self.bot.user.public_flags.verified_bot:
buttons = disnake.ui.ActionRow(
Expand Down

0 comments on commit 79951de

Please sign in to comment.