Skip to content

Commit

Permalink
ClashKing v4
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicTheDev committed Mar 24, 2024
1 parent 41a5c44 commit b12dc50
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
24 changes: 5 additions & 19 deletions classes/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def __init__(self, config: Config, command_prefix: str, help_command, intents: d
self.button_store: collection_class = self.looper_db.clashking.button_store
self.legend_rankings: collection_class = self.new_looper.legend_rankings
self.war_timers: collection_class = self.looper_db.looper.war_timer
self.number_emojis: collection_class = self.looper_db.clashking.number_emojis


self.db_client = motor.motor_asyncio.AsyncIOMotorClient(self._config.static_mongodb)
Expand Down Expand Up @@ -120,7 +121,6 @@ def __init__(self, config: Config, command_prefix: str, help_command, intents: d
self.custom_bots: collection_class = self.db_client.usafam.custom_bots
self.suggestions: collection_class = self.db_client.usafam.suggestions


self.tickets: collection_class = self.db_client.usafam.tickets
self.open_tickets: collection_class = self.db_client.usafam.open_tickets
self.custom_embeds: collection_class = self.db_client.usafam.custom_embeds
Expand Down Expand Up @@ -154,6 +154,8 @@ def __init__(self, config: Config, command_prefix: str, help_command, intents: d
self.EXTENSION_LIST = []
self.STARTED_CHUNK = set()

self.number_emoji_map = {}


def clean_string(self, text: str):
text = emoji.replace_emoji(text)
Expand Down Expand Up @@ -215,24 +217,8 @@ async def create_new_badge_emoji(self, url:str):
def get_number_emoji(self, color: str, number: int) -> EmojiType:
if not self.user.id == 808566437199216691 and not self.user.public_flags.verified_bot:
color = "gold"
guild = None
if number <= 50:
if color == "white":
guild = self.get_guild(1042301258167484426)
elif color == "blue":
guild = self.get_guild(1042222078302109779)
elif color == "gold":
guild = self.get_guild(1042301195240357958)
elif number >= 51:
if color == "white":
guild = self.get_guild(1042635651562086430)
elif color == "blue":
guild = self.get_guild(1042635521890992158)
elif color == "gold":
guild = self.get_guild(1042635608088125491)
all_emojis = guild.emojis
emoji = disnake.utils.get(all_emojis, name=f"{number}_")
return EmojiType(emoji_string=f"<:{emoji.name}:{emoji.id}>")
emoji = self.number_emoji_map.get(color).get(number)
return EmojiType(emoji_string=emoji)


async def track_clans(self, tags: list):
Expand Down
13 changes: 11 additions & 2 deletions discord/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from classes.tickets import OpenTicket, TicketPanel, LOG_TYPE
from classes.DatabaseClient.familyclient import FamilyClient
from assets.emojiDictionary import switcher, emoji_class_dict

from pymongo import UpdateOne

class DiscordEvents(commands.Cog):

Expand All @@ -25,8 +25,8 @@ async def on_connect(self):
return
global has_started
if not has_started:
await asyncio.sleep(5)
has_started = True
await asyncio.sleep(15)
if self.bot.user.public_flags.verified_bot:
for count, shard in self.bot.shards.items():
await self.bot.change_presence(activity=disnake.CustomActivity(state="Use Code ClashKing 👀", name="Custom Status"), shard_id=shard.id)
Expand All @@ -44,6 +44,15 @@ async def on_connect(self):
"lbboardChannel": None,
"lbhour": None,
})

number_emojis = await self.bot.number_emojis.find().to_list(length=None)
number_emojis_map = {"blue" : {}, "gold" : {}, "white" : {}}
for emoji in number_emojis:
number_emojis_map[emoji.get("color")][emoji.get("count")] = emoji.get("emoji_id")
self.bot.number_emoji_map = number_emojis_map



'''if not self.bot.user.public_flags.verified_bot and self.bot.user.id != 808566437199216691:
largest_server = sorted(self.bot.guilds, key=lambda x: x.member_count, reverse=True)[0]
for server in self.bot.guilds:
Expand Down

0 comments on commit b12dc50

Please sign in to comment.