diff --git a/announcedaily/__init__.py b/announcedaily/__init__.py index 8cc69d5e..8dcdbe4e 100644 --- a/announcedaily/__init__.py +++ b/announcedaily/__init__.py @@ -3,7 +3,9 @@ from .announcedaily import AnnounceDaily -def setup(bot: Red): +async def setup(bot: Red): daily = AnnounceDaily(bot) - bot.add_cog(daily) - bot.loop.create_task(daily.check_day()) + r = bot.add_cog(daily) + if r is not None: + await r + bot.loop.create_task(daily.check_day()) diff --git a/audiotrivia/__init__.py b/audiotrivia/__init__.py index 6cb34edf..83acf584 100644 --- a/audiotrivia/__init__.py +++ b/audiotrivia/__init__.py @@ -6,8 +6,11 @@ async def setup(bot: Red): if bot.get_cog("Trivia"): print("Trivia is already loaded, attempting to unload it first") - bot.remove_cog("Trivia") + await bot.remove_cog("Trivia") await bot.remove_loaded_package("trivia") - bot.unload_extension("trivia") + await bot.unload_extension("trivia") - bot.add_cog(AudioTrivia(bot)) + cog = AudioTrivia(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/ccrole/__init__.py b/ccrole/__init__.py index a22b3f16..1a0e5dc6 100644 --- a/ccrole/__init__.py +++ b/ccrole/__init__.py @@ -1,5 +1,8 @@ from .ccrole import CCRole -def setup(bot): - bot.add_cog(CCRole(bot)) +async def setup(bot): + cog = CCRole(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/ccrole/ccrole.py b/ccrole/ccrole.py index 1f90a80b..8f9d0202 100644 --- a/ccrole/ccrole.py +++ b/ccrole/ccrole.py @@ -3,7 +3,12 @@ import re import discord -from discord.ext.commands import RoleConverter, Greedy, CommandError, ArgumentParsingError +from discord.ext.commands import ( + RoleConverter, + Greedy, + CommandError, + ArgumentParsingError, +) from discord.ext.commands.view import StringView from redbot.core import Config, checks, commands from redbot.core.bot import Red @@ -107,10 +112,7 @@ async def ccrole_add(self, ctx, command: str): return # Roles to add - await ctx.send( - "What roles should it add?\n" - "Say `None` to skip adding roles" - ) + await ctx.send("What roles should it add?\n" "Say `None` to skip adding roles") def check(m): return m.author == author and m.channel == channel @@ -129,10 +131,7 @@ def check(m): return # Roles to remove - await ctx.send( - "What roles should it remove?\n" - "Say `None` to skip removing roles" - ) + await ctx.send("What roles should it remove?\n" "Say `None` to skip removing roles") try: answer = await self.bot.wait_for("message", timeout=120, check=check) except asyncio.TimeoutError: @@ -148,8 +147,7 @@ def check(m): # Roles to use await ctx.send( - "What roles are allowed to use this command?\n" - "Say `None` to allow all roles" + "What roles are allowed to use this command?\n" "Say `None` to allow all roles" ) try: diff --git a/chatter/__init__.py b/chatter/__init__.py index 663dadf4..9efb7df7 100644 --- a/chatter/__init__.py +++ b/chatter/__init__.py @@ -4,7 +4,9 @@ async def setup(bot): cog = Chatter(bot) await cog.initialize() - bot.add_cog(cog) + r = bot.add_cog(cog) + if r is not None: + await r # __all__ = ( diff --git a/chatter/chat.py b/chatter/chat.py index 765afd17..43f3a1a9 100644 --- a/chatter/chat.py +++ b/chatter/chat.py @@ -9,9 +9,17 @@ import discord from chatterbot import ChatBot -from chatterbot.comparisons import JaccardSimilarity, LevenshteinDistance, SpacySimilarity +from chatterbot.comparisons import ( + JaccardSimilarity, + LevenshteinDistance, + SpacySimilarity, +) from chatterbot.response_selection import get_random_response -from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer, UbuntuCorpusTrainer +from chatterbot.trainers import ( + ChatterBotCorpusTrainer, + ListTrainer, + UbuntuCorpusTrainer, +) from redbot.core import Config, checks, commands from redbot.core.commands import Cog from redbot.core.data_manager import cog_data_path @@ -66,7 +74,12 @@ def __init__(self, bot): super().__init__() self.bot = bot self.config = Config.get_conf(self, identifier=6710497116116101114) - default_global = {"learning": True, "model_number": 0, "algo_number": 0, "threshold": 0.90} + default_global = { + "learning": True, + "model_number": 0, + "algo_number": 0, + "threshold": 0.90, + } self.default_guild = { "whitelist": None, "days": 1, @@ -115,7 +128,6 @@ async def initialize(self): self.chatbot = self._create_chatbot() def _create_chatbot(self): - return ChatBot( "ChatterBot", # storage_adapter="chatterbot.storage.SQLStorageAdapter", @@ -155,7 +167,6 @@ def new_conversation(msg, sent, out_in, delta): send_time = after - timedelta(days=100) # Makes the first message a new message try: - async for message in channel.history( limit=None, after=after, oldest_first=True ).filter( @@ -195,7 +206,8 @@ def _train_twitter(self, *args, **kwargs): def _train_ubuntu(self): trainer = UbuntuCorpusTrainer( - self.chatbot, ubuntu_corpus_data_directory=cog_data_path(self) / "ubuntu_data" + self.chatbot, + ubuntu_corpus_data_directory=cog_data_path(self) / "ubuntu_data", ) trainer.train() return True @@ -696,7 +708,6 @@ async def on_message_without_command(self, message: discord.Message): text = message.clean_content async with ctx.typing(): - if is_reply: in_response_to = message.reference.resolved.content elif self._last_message_per_channel[ctx.channel.id] is not None: diff --git a/coglint/__init__.py b/coglint/__init__.py index 87f61bb0..6b03304d 100644 --- a/coglint/__init__.py +++ b/coglint/__init__.py @@ -1,5 +1,8 @@ from .coglint import CogLint -def setup(bot): - bot.add_cog(CogLint(bot)) +async def setup(bot): + cog = CogLint(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/conquest/__init__.py b/conquest/__init__.py index bb8992e7..ad455959 100644 --- a/conquest/__init__.py +++ b/conquest/__init__.py @@ -9,7 +9,11 @@ async def setup(bot): data_manager.bundled_data_path(cog) await cog.load_data() - bot.add_cog(cog) + r = bot.add_cog(cog) + if r is not None: + await r - cog2 = MapMaker(bot) - bot.add_cog(cog2) + cog2 = MapMaker(bot) + r2 = bot.add_cog(cog2) + if r2 is not None: + await r2 diff --git a/conquest/conquest.py b/conquest/conquest.py index 2c3772cc..7a5d058a 100644 --- a/conquest/conquest.py +++ b/conquest/conquest.py @@ -328,7 +328,8 @@ async def _conquest_numbered(self, ctx: commands.Context): ) current_numbered_img.save( - self.data_path / self.current_map / f"current_numbered.{self.ext}", self.ext_format + self.data_path / self.current_map / f"current_numbered.{self.ext}", + self.ext_format, ) await self._send_maybe_zoomed_map( diff --git a/conquest/regioner.py b/conquest/regioner.py index b89bc5f5..194dfaec 100644 --- a/conquest/regioner.py +++ b/conquest/regioner.py @@ -51,8 +51,8 @@ def floodfill(image, xy, value, border=None, thresh=0) -> set: while edge: filled_pixels.update(edge) new_edge = set() - for (x, y) in edge: # 4 adjacent method - for (s, t) in ((x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)): + for x, y in edge: # 4 adjacent method + for s, t in ((x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)): # If already processed, or if a coordinate is negative, skip if (s, t) in full_edge or s < 0 or t < 0: continue @@ -76,7 +76,11 @@ def floodfill(image, xy, value, border=None, thresh=0) -> set: class Regioner: def __init__( - self, filepath: pathlib.Path, filename: str, wall_color="black", region_color="white" + self, + filepath: pathlib.Path, + filename: str, + wall_color="black", + region_color="white", ): self.filepath = filepath self.filename = filename diff --git a/dad/__init__.py b/dad/__init__.py index 0b94f16b..b5a52f2b 100644 --- a/dad/__init__.py +++ b/dad/__init__.py @@ -1,5 +1,8 @@ from .dad import Dad -def setup(bot): - bot.add_cog(Dad(bot)) +async def setup(bot): + cog = Dad(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/exclusiverole/__init__.py b/exclusiverole/__init__.py index 87978456..0959e2a2 100644 --- a/exclusiverole/__init__.py +++ b/exclusiverole/__init__.py @@ -1,5 +1,8 @@ from .exclusiverole import ExclusiveRole -def setup(bot): - bot.add_cog(ExclusiveRole(bot)) +async def setup(bot): + cog = ExclusiveRole(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/fifo/__init__.py b/fifo/__init__.py index 4f3f131c..e3f76043 100644 --- a/fifo/__init__.py +++ b/fifo/__init__.py @@ -19,5 +19,5 @@ async def setup(bot): await cog.initialize() -def teardown(bot): +async def teardown(bot): pass diff --git a/fifo/fifo.py b/fifo/fifo.py index 24d01f3b..46d97cdb 100644 --- a/fifo/fifo.py +++ b/fifo/fifo.py @@ -14,7 +14,11 @@ from redbot.core.commands import TimedeltaConverter from redbot.core.utils.chat_formatting import humanize_timedelta, pagify -from .datetime_cron_converters import CronConverter, DatetimeConverter, TimezoneConverter +from .datetime_cron_converters import ( + CronConverter, + DatetimeConverter, + TimezoneConverter, +) from .task import Task schedule_log = logging.getLogger("red.fox_v3.fifo.scheduler") @@ -104,7 +108,6 @@ def cog_unload(self): self.scheduler.shutdown() async def initialize(self): - job_defaults = { "coalesce": True, # Multiple missed triggers within the grace time will only fire once "max_instances": 5, # This is probably way too high, should likely only be one @@ -117,7 +120,9 @@ async def initialize(self): # Default executor is already AsyncIOExecutor self.scheduler = AsyncIOScheduler(job_defaults=job_defaults, logger=schedule_log) - from .redconfigjobstore import RedConfigJobStore # Wait to import to prevent cyclic import + from .redconfigjobstore import ( + RedConfigJobStore, + ) # Wait to import to prevent cyclic import self.jobstore = RedConfigJobStore(self.config, self.bot) await self.jobstore.load_from_config() @@ -375,7 +380,9 @@ async def fifo_details(self, ctx: commands.Context, task_name: str): embed = discord.Embed(title=f"Task: {task_name}") embed.add_field( - name="Task command", value=f"{ctx.prefix}{task.get_command_str()}", inline=False + name="Task command", + value=f"{ctx.prefix}{task.get_command_str()}", + inline=False, ) guild: discord.Guild = self.bot.get_guild(task.guild_id) @@ -470,7 +477,14 @@ async def fifo_add(self, ctx: commands.Context, task_name: str, *, command_to_ex ) return - task = Task(task_name, ctx.guild.id, self.config, ctx.author.id, ctx.channel.id, self.bot) + task = Task( + task_name, + ctx.guild.id, + self.config, + ctx.author.id, + ctx.channel.id, + self.bot, + ) await task.set_commmand_str(command_to_execute) await task.save_all() await ctx.tick() @@ -553,7 +567,11 @@ async def fifo_trigger_interval( @fifo_trigger.command(name="relative") async def fifo_trigger_relative( - self, ctx: commands.Context, task_name: str, *, time_from_now: TimedeltaConverter + self, + ctx: commands.Context, + task_name: str, + *, + time_from_now: TimedeltaConverter, ): """ Add a "run once" trigger at a time relative from now to the specified task diff --git a/fifo/task.py b/fifo/task.py index 4ab28090..c96e94cf 100644 --- a/fifo/task.py +++ b/fifo/task.py @@ -92,7 +92,7 @@ def parse_triggers(data: Union[Dict, None]): "content", "nonce", "reference", - "_edited_timestamp" # New 7/23/21 + "_edited_timestamp", # New 7/23/21 ] things_fakemessage_sets_by_default = { @@ -119,11 +119,15 @@ def __init__(self, *args, message: discord.Message, **kwargs): self.id = time_snowflake(datetime.utcnow(), high=False) # Pretend to be now self.type = discord.MessageType.default - def _rebind_cached_references_backport(self, guild: discord.Guild, channel: discord.TextChannel) -> Callable: + def _rebind_cached_references_backport( + self, guild: discord.Guild, channel: discord.TextChannel + ) -> Callable: def check_sig(method_name, *params): method = getattr(self, method_name, None) - return method and ismethod(method) and list(signature(method).parameters) == list(params) - + return ( + method and ismethod(method) and list(signature(method).parameters) == list(params) + ) + if check_sig("_rebind_cached_references", "new_guild", "new_channel"): self._rebind_cached_references(guild, channel) elif check_sig("_rebind_channel_reference", "new_channel"): @@ -199,7 +203,13 @@ class Task: } def __init__( - self, name: str, guild_id, config: Config, author_id=None, channel_id=None, bot: Red = None + self, + name: str, + guild_id, + config: Config, + author_id=None, + channel_id=None, + bot: Red = None, ): self.name = name self.guild_id = guild_id @@ -220,7 +230,10 @@ async def _encode_time_triggers(self): td: timedelta = t["time_data"] triggers.append( - {"type": t["type"], "time_data": {"days": td.days, "seconds": td.seconds}} + { + "type": t["type"], + "time_data": {"days": td.days, "seconds": td.seconds}, + } ) continue diff --git a/flag/__init__.py b/flag/__init__.py index 0184952b..08ec1769 100644 --- a/flag/__init__.py +++ b/flag/__init__.py @@ -1,5 +1,7 @@ from .flag import Flag -def setup(bot): - bot.add_cog(Flag(bot)) +async def setup(bot): + r = bot.add_cog(Flag(bot)) + if r is not None: + await r diff --git a/forcemention/__init__.py b/forcemention/__init__.py index a2a8ee76..0cf256c3 100644 --- a/forcemention/__init__.py +++ b/forcemention/__init__.py @@ -1,5 +1,8 @@ from .forcemention import ForceMention -def setup(bot): - bot.add_cog(ForceMention(bot)) +async def setup(bot): + cog = ForceMention(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/hangman/__init__.py b/hangman/__init__.py index 35012c4a..10262117 100644 --- a/hangman/__init__.py +++ b/hangman/__init__.py @@ -2,7 +2,9 @@ from redbot.core import data_manager -def setup(bot): - n = Hangman(bot) - data_manager.bundled_data_path(n) - bot.add_cog(n) +async def setup(bot): + cog = Hangman(bot) + data_manager.bundled_data_path(cog) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/infochannel/__init__.py b/infochannel/__init__.py index bbff9012..c77f34e4 100644 --- a/infochannel/__init__.py +++ b/infochannel/__init__.py @@ -2,6 +2,8 @@ async def setup(bot): - ic_cog = InfoChannel(bot) - bot.add_cog(ic_cog) - await ic_cog.initialize() + cog = InfoChannel(bot) + r = bot.add_cog(cog) + if r is not None: + await r + await cog.initialize() diff --git a/infochannel/infochannel.py b/infochannel/infochannel.py index e8ea91b1..938526f2 100644 --- a/infochannel/infochannel.py +++ b/infochannel/infochannel.py @@ -82,7 +82,11 @@ def __init__(self, bot: Red): self.config.register_guild(**default_guild) - self.default_role = {"enabled": False, "channel_id": None, "name": "{role}: {count}"} + self.default_role = { + "enabled": False, + "channel_id": None, + "name": "{role}: {count}", + } self.config.register_role(**self.default_role) @@ -503,17 +507,16 @@ async def trigger_updates_for(self, guild, **kwargs): extra_roles: Optional[set] = kwargs.pop("extra_roles", False) guild_data = await self.config.guild(guild).all() - to_update = ( - kwargs.keys() & [key for key, value in guild_data["enabled_channels"].items() if value] - ) # Value in kwargs doesn't matter + to_update = kwargs.keys() & [ + key for key, value in guild_data["enabled_channels"].items() if value + ] # Value in kwargs doesn't matter if to_update or extra_roles: - log.debug(f"{to_update=}\n" - f"{extra_roles=}") + log.debug(f"{to_update=}\n" f"{extra_roles=}") category = guild.get_channel(guild_data["category_id"]) if category is None: - log.debug('Channel category is missing, updating must be off') + log.debug("Channel category is missing, updating must be off") return # Nothing to update, must be off channel_data = await get_channel_counts(category, guild) diff --git a/isitdown/__init__.py b/isitdown/__init__.py index fdebc2aa..53ae9f8e 100644 --- a/isitdown/__init__.py +++ b/isitdown/__init__.py @@ -2,4 +2,7 @@ async def setup(bot): - bot.add_cog(IsItDown(bot)) + cog = IsItDown(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/launchlib/__init__.py b/launchlib/__init__.py index 8e45f6eb..2c56fb78 100644 --- a/launchlib/__init__.py +++ b/launchlib/__init__.py @@ -1,5 +1,8 @@ from .launchlib import LaunchLib -def setup(bot): - bot.add_cog(LaunchLib(bot)) +async def setup(bot): + cog = LaunchLib(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/launchlib/launchlib.py b/launchlib/launchlib.py index 2a30c3ef..f812a7c0 100644 --- a/launchlib/launchlib.py +++ b/launchlib/launchlib.py @@ -35,7 +35,6 @@ async def red_delete_data_for_user(self, **kwargs): return async def _embed_launch_data(self, launch: ll.AsyncLaunch): - # status: ll.AsyncLaunchStatus = await launch.get_status() status = launch.status diff --git a/leaver/__init__.py b/leaver/__init__.py index ed6689b0..0b516f8c 100644 --- a/leaver/__init__.py +++ b/leaver/__init__.py @@ -1,5 +1,8 @@ from .leaver import Leaver -def setup(bot): - bot.add_cog(Leaver(bot)) +async def setup(bot): + cog = Leaver(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/leaver/leaver.py b/leaver/leaver.py index 76f29f58..5c0ef4a9 100644 --- a/leaver/leaver.py +++ b/leaver/leaver.py @@ -48,7 +48,7 @@ async def on_member_remove(self, member: discord.Member): out = "{}{} has left the server".format( member, member.nick if member.nick is not None else "" ) - if await self.bot.embed_requested(channel, member): + if await self.bot.embed_requested(channel): await channel.send( embed=discord.Embed( description=out, color=(await self.bot.get_embed_color(channel)) diff --git a/lovecalculator/__init__.py b/lovecalculator/__init__.py index 5284684e..99d7e520 100644 --- a/lovecalculator/__init__.py +++ b/lovecalculator/__init__.py @@ -1,5 +1,8 @@ from .lovecalculator import LoveCalculator -def setup(bot): - bot.add_cog(LoveCalculator(bot)) +async def setup(bot): + cog = LoveCalculator(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/lseen/__init__.py b/lseen/__init__.py index 716f34d6..b57e0f4f 100644 --- a/lseen/__init__.py +++ b/lseen/__init__.py @@ -1,5 +1,8 @@ from .lseen import LastSeen -def setup(bot): - bot.add_cog(LastSeen(bot)) +async def setup(bot): + cog = LastSeen(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/lseen/lseen.py b/lseen/lseen.py index f77fbca0..5e22730a 100644 --- a/lseen/lseen.py +++ b/lseen/lseen.py @@ -36,7 +36,6 @@ async def red_delete_data_for_user( requester: Literal["discord_deleted_user", "owner", "user", "user_strict"], user_id: int, ): - all_members = await self.config.all_members() async for guild_id, guild_data in AsyncIter(all_members.items(), steps=100): diff --git a/nudity/__init__.py b/nudity/__init__.py index 09d9dbfd..2d9a4148 100644 --- a/nudity/__init__.py +++ b/nudity/__init__.py @@ -1,6 +1,8 @@ from .nudity import Nudity -def setup(bot): - n = Nudity(bot) - bot.add_cog(n) +async def setup(bot): + cog = Nudity(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/planttycoon/__init__.py b/planttycoon/__init__.py index 7819b904..1afad4fd 100644 --- a/planttycoon/__init__.py +++ b/planttycoon/__init__.py @@ -4,7 +4,9 @@ async def setup(bot): - tycoon = PlantTycoon(bot) - data_manager.bundled_data_path(tycoon) - await tycoon._load_plants_products() # I can access protected members if I want, linter!! - bot.add_cog(tycoon) + cog = PlantTycoon(bot) + data_manager.bundled_data_path(cog) + await cog._load_plants_products() # I can access protected members if I want, linter!! + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/planttycoon/planttycoon.py b/planttycoon/planttycoon.py index 0dbded9f..86328874 100644 --- a/planttycoon/planttycoon.py +++ b/planttycoon/planttycoon.py @@ -52,7 +52,6 @@ async def save_gardener(self): await self.config.user(self.user).current.set(self.current) async def is_complete(self, now): - message = None if self.current: then = self.current["timestamp"] @@ -186,7 +185,6 @@ async def red_delete_data_for_user( requester: Literal["discord_deleted_user", "owner", "user", "user_strict"], user_id: int, ): - await self.config.user_from_id(user_id).clear() async def _load_plants_products(self): @@ -226,7 +224,6 @@ async def _load_event_seeds(self): plant_options.append(self.plants["event"]["December"]) async def _gardener(self, user: discord.User) -> Gardener: - # # This function returns a Gardener object for the user # @@ -236,7 +233,6 @@ async def _gardener(self, user: discord.User) -> Gardener: return g async def _degradation(self, gardener: Gardener): - # # Calculating the rate of degradation per check_completion_loop() cycle. # @@ -278,7 +274,6 @@ async def _degradation(self, gardener: Gardener): # await self.bot.send_message(member, embed=em) async def _add_health(self, channel, gardener: Gardener, product, product_category): - # # The function to add health # diff --git a/qrinvite/__init__.py b/qrinvite/__init__.py index a91023a9..4068ce49 100644 --- a/qrinvite/__init__.py +++ b/qrinvite/__init__.py @@ -1,5 +1,8 @@ from .qrinvite import QRInvite -def setup(bot): - bot.add_cog(QRInvite(bot)) +async def setup(bot): + cog = QRInvite(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/reactrestrict/__init__.py b/reactrestrict/__init__.py index 8bd425f0..3c1b2a29 100644 --- a/reactrestrict/__init__.py +++ b/reactrestrict/__init__.py @@ -1,5 +1,8 @@ from .reactrestrict import ReactRestrict -def setup(bot): - bot.add_cog(ReactRestrict(bot)) +async def setup(bot): + cog = ReactRestrict(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/recyclingplant/__init__.py b/recyclingplant/__init__.py index c86df1c6..09b73fac 100644 --- a/recyclingplant/__init__.py +++ b/recyclingplant/__init__.py @@ -3,7 +3,9 @@ from .recyclingplant import RecyclingPlant -def setup(bot): - plant = RecyclingPlant(bot) - data_manager.bundled_data_path(plant) - bot.add_cog(plant) +async def setup(bot): + cog = RecyclingPlant(bot) + data_manager.bundled_data_path(cog) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/recyclingplant/recyclingplant.py b/recyclingplant/recyclingplant.py index 37516482..349d6cbf 100644 --- a/recyclingplant/recyclingplant.py +++ b/recyclingplant/recyclingplant.py @@ -102,6 +102,8 @@ def check(m): await bank.deposit_credits(ctx.author, reward) await ctx.send( "{} been given **{} {}s** for your services.".format( - ctx.author.display_name, reward, await bank.get_currency_name(ctx.guild) + ctx.author.display_name, + reward, + await bank.get_currency_name(ctx.guild), ) ) diff --git a/rpsls/__init__.py b/rpsls/__init__.py index 46a16001..1c7cc345 100644 --- a/rpsls/__init__.py +++ b/rpsls/__init__.py @@ -1,5 +1,8 @@ from .rpsls import RPSLS -def setup(bot): - bot.add_cog(RPSLS(bot)) +async def setup(bot): + cog = RPSLS(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/sayurl/__init__.py b/sayurl/__init__.py index f4440e1b..52a5e2b3 100644 --- a/sayurl/__init__.py +++ b/sayurl/__init__.py @@ -1,5 +1,8 @@ from .sayurl import SayUrl -def setup(bot): - bot.add_cog(SayUrl(bot)) +async def setup(bot): + cog = SayUrl(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/scp/__init__.py b/scp/__init__.py index bded2a52..5b42fbce 100644 --- a/scp/__init__.py +++ b/scp/__init__.py @@ -1,5 +1,8 @@ from .scp import SCP -def setup(bot): - bot.add_cog(SCP(bot)) +async def setup(bot): + cog = SCP(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/stealemoji/__init__.py b/stealemoji/__init__.py index 67b3dea2..fe078358 100644 --- a/stealemoji/__init__.py +++ b/stealemoji/__init__.py @@ -1,5 +1,8 @@ from .stealemoji import StealEmoji -def setup(bot): - bot.add_cog(StealEmoji(bot)) +async def setup(bot): + cog = StealEmoji(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/timerole/__init__.py b/timerole/__init__.py index 9e7f94bb..fdf4959e 100644 --- a/timerole/__init__.py +++ b/timerole/__init__.py @@ -1,5 +1,8 @@ from .timerole import Timerole -def setup(bot): - bot.add_cog(Timerole(bot)) +async def setup(bot): + cog = Timerole(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/timerole/timerole.py b/timerole/timerole.py index 14a0bb46..1876260c 100644 --- a/timerole/timerole.py +++ b/timerole/timerole.py @@ -37,7 +37,12 @@ def __init__(self, bot: Red): self.bot = bot self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True) default_global = {} - default_guild = {"announce": None, "reapply": True, "roles": {}, "skipbots": True} + default_guild = { + "announce": None, + "reapply": True, + "roles": {}, + "skipbots": True, + } default_rolemember = {"had_role": False, "check_again_time": None} self.config.register_global(**default_global) @@ -81,7 +86,11 @@ async def timerole(self, ctx): @timerole.command() async def addrole( - self, ctx: commands.Context, role: discord.Role, time: str, *requiredroles: discord.Role + self, + ctx: commands.Context, + role: discord.Role, + time: str, + *requiredroles: discord.Role, ): """Add a role to be added after specified time on server""" guild = ctx.guild @@ -109,7 +118,11 @@ async def addrole( @timerole.command() async def removerole( - self, ctx: commands.Context, role: discord.Role, time: str, *requiredroles: discord.Role + self, + ctx: commands.Context, + role: discord.Role, + time: str, + *requiredroles: discord.Role, ): """ Add a role to be removed after specified time on server @@ -220,7 +233,6 @@ async def timerole_update(self): # log.debug(f"{all_mr=}") async for member in AsyncIter(guild.members, steps=10): - if member.bot and skipbots: continue diff --git a/tts/__init__.py b/tts/__init__.py index 47959b8d..46991582 100644 --- a/tts/__init__.py +++ b/tts/__init__.py @@ -1,5 +1,8 @@ from .tts import TTS -def setup(bot): - bot.add_cog(TTS(bot)) +async def setup(bot): + cog = TTS(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/tts/tts.py b/tts/tts.py index 34473f35..dd0850aa 100644 --- a/tts/tts.py +++ b/tts/tts.py @@ -65,7 +65,11 @@ async def ttslang(self, ctx: commands.Context, lang: ISO639Converter): @commands.command(aliases=["t2s", "text2"]) @commands.guild_only() async def tts( - self, ctx: commands.Context, lang: Optional[ISO639Converter] = None, *, text: str + self, + ctx: commands.Context, + lang: Optional[ISO639Converter] = None, + *, + text: str, ): """ Send Text to speech messages as an mp3 diff --git a/unicode/__init__.py b/unicode/__init__.py index 410d42c9..dacdadd3 100644 --- a/unicode/__init__.py +++ b/unicode/__init__.py @@ -1,5 +1,8 @@ from .unicode import Unicode -def setup(bot): - bot.add_cog(Unicode(bot)) +async def setup(bot): + cog = Unicode(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/werewolf/__init__.py b/werewolf/__init__.py index cefe6ade..f3722456 100644 --- a/werewolf/__init__.py +++ b/werewolf/__init__.py @@ -1,5 +1,8 @@ from .werewolf import Werewolf -def setup(bot): - bot.add_cog(Werewolf(bot)) +async def setup(bot): + cog = Werewolf(bot) + r = bot.add_cog(cog) + if r is not None: + await r diff --git a/werewolf/builder.py b/werewolf/builder.py index 28098be6..75b6a811 100644 --- a/werewolf/builder.py +++ b/werewolf/builder.py @@ -48,7 +48,9 @@ def role_embed(idx, role: Role, color): embed.set_thumbnail(url=role.icon_url) embed.add_field( - name="Alignment", value=["Town", "Werewolf", "Neutral"][role.alignment - 1], inline=False + name="Alignment", + value=["Town", "Werewolf", "Neutral"][role.alignment - 1], + inline=False, ) embed.add_field(name="Multiples Allowed", value=str(not role.unique), inline=False) embed.add_field( diff --git a/werewolf/converters.py b/werewolf/converters.py index f1086666..94e0c665 100644 --- a/werewolf/converters.py +++ b/werewolf/converters.py @@ -13,7 +13,6 @@ class PlayerConverter(Converter): async def convert(self, ctx, argument) -> Player: - try: target = await commands.MemberConverter().convert(ctx, argument) except BadArgument: diff --git a/werewolf/game.py b/werewolf/game.py index 949381c1..df478857 100644 --- a/werewolf/game.py +++ b/werewolf/game.py @@ -194,7 +194,9 @@ async def setup(self, ctx: commands.Context): } if self.channel_category is None: self.channel_category = await self.guild.create_category( - "Werewolf Game", overwrites=overwrite, reason="(BOT) New game of werewolf" + "Werewolf Game", + overwrites=overwrite, + reason="(BOT) New game of werewolf", ) else: # No need to modify categories pass @@ -233,7 +235,9 @@ async def setup(self, ctx: commands.Context): curr = self.village_channel.overwrites_for(target) curr.update(**{perm: value for perm, value in ow}) await self.village_channel.set_permissions( - target=target, overwrite=curr, reason="(BOT) New game of werewolf" + target=target, + overwrite=curr, + reason="(BOT) New game of werewolf", ) except discord.Forbidden: await ctx.maybe_send_embed( @@ -445,7 +449,6 @@ async def _at_voted(self, target): # ID 2 await self.lynch(target) self.any_votes_remaining = False else: - if self.used_votes >= self.day_vote_count: await self.village_channel.send("**All votes have been used! Day is now over!**") self.any_votes_remaining = False @@ -565,7 +568,9 @@ async def generate_targets(self, channel, with_roles=False): ) else: embed.add_field( - name=f"{i} - {status}{player.member.display_name}", inline=False, value="____" + name=f"{i} - {status}{player.member.display_name}", + inline=False, + value="____", ) return await channel.send(embed=embed) @@ -755,7 +760,9 @@ async def _village_vote(self, target, author, target_id): async def eval_results(self, target, source=None, method=None): if method is None: return "**{ID}** - {target} the {role} was found dead".format( - ID=target.id, target=target.member.display_name, role=await target.role.get_role() + ID=target.id, + target=target.member.display_name, + role=await target.role.get_role(), ) out = "**{ID}** - " + method diff --git a/werewolf/roles/vanillawerewolf.py b/werewolf/roles/vanillawerewolf.py index 8abdea21..e11c6ffe 100644 --- a/werewolf/roles/vanillawerewolf.py +++ b/werewolf/roles/vanillawerewolf.py @@ -1,6 +1,10 @@ import logging -from werewolf.constants import ALIGNMENT_WEREWOLF, CATEGORY_WW_KILLING, CATEGORY_WW_RANDOM +from werewolf.constants import ( + ALIGNMENT_WEREWOLF, + CATEGORY_WW_KILLING, + CATEGORY_WW_RANDOM, +) from werewolf.listener import wolflistener from werewolf.role import Role from werewolf.votegroups.wolfvote import WolfVote