From c97a75a12999f638cd413d8e0dbd623102cdd1b8 Mon Sep 17 00:00:00 2001 From: kwzrd Date: Sun, 29 Mar 2020 13:30:30 +0200 Subject: Deseasonify: remove unused `set_username` method The method is a left-over from the old seasonal system. We no longer use it, the bot's username never changes, only the nickname. The amount of internal branching logic makes it difficult to maintain. --- bot/bot.py | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'bot/bot.py') diff --git a/bot/bot.py b/bot/bot.py index 3e20e3ab..b9ebb7f2 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -136,36 +136,6 @@ class SeasonalBot(commands.Bot): async with self.http_session.get(url) as resp: return await resp.read() - @mock_in_debug(return_value=True) - async def set_username(self, new_name: str, nick_only: bool = False) -> Optional[bool]: - """ - Set the bot username and/or nickname to given new name. - - Returns True/False based on success, or None if nickname fallback also failed. - """ - old_username = self.user.name - - if nick_only: - return await self.set_nickname(new_name) - - if old_username == new_name: - # since the username is correct, make sure nickname is removed - return await self.set_nickname() - - log.debug(f"Changing username to {new_name}") - with contextlib.suppress(discord.HTTPException): - await bot.user.edit(username=new_name, nick=None) - - if not new_name == self.member.display_name: - # name didn't change, try to changing nickname as fallback - if await self.set_nickname(new_name): - log.warning(f"Changing username failed, changed nickname instead.") - return False - log.warning(f"Changing username and nickname failed.") - return None - - return True - @mock_in_debug(return_value=True) async def set_nickname(self, new_name: str = None) -> bool: """Set the bot nickname in the main guild.""" -- cgit v1.2.3