def setup(bot: Red) -> None: cog = bot.get_cog("CustomCommands") if cog: raise CogLoadError( "This cog conflicts with CustomCommands and cannot be loaded with both at the same time." ) bot.add_cog(Tags(bot))
def setup(bot: Red): if not bot._cli_flags.dev: raise CogLoadError("This cog requires the `--dev` CLI flag.") if getattr(bot.get_cog("Dev"), "sessions", None): raise CogLoadError("End your REPL session(s) first.") bot.remove_cog("Dev") bot.add_cog(Dev())
def setup(bot: Red) -> None: apc = AnotherPingCog(bot) global old_ping old_ping = bot.get_command("ping") if old_ping: bot.remove_command(old_ping.name) bot.add_cog(apc)
async def setup(bot: Red) -> None: await maybe_migrate_config_identifier() cog = Status(bot) await out_of_date_check("status", cog.__version__) await cog.async_init() bot.add_cog(cog)
async def setup(bot: Red) -> None: if version_info < VersionInfo.from_str("3.1.3"): raise CogLoadError( "This cog requires at least Red 3.1.3.\n" "Go update, it's a straight improvement from previously supported versions." ) bot.add_cog(VoiceTools())
def setup(bot: Red) -> None: cog = bot.get_cog("CustomCommands") if cog: raise CogLoadError( "This cog conflicts with CustomCommands and both cannot be loaded at the same time. " "After unloading `customcom`, you can migrate custom commands to tags with `[p]migratecustomcom`." ) bot.add_cog(Tags(bot))
def setup(bot: Red) -> None: for cog_name, module_name, tag_name in conflicting_cogs: if bot.get_cog(cog_name): raise CogLoadError( f"This cog conflicts with {cog_name} and both cannot be loaded at the same time. " f"After unloading `{module_name}`, you can migrate {tag_name} to tags with `[p]migrate{module_name}`." ) bot.add_cog(Tags(bot))
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_loaded_package("trivia") bot.unload_extension("trivia") bot.add_cog(AudioTrivia(bot))
async def setup(bot: Red): try: cog = Crossbar(bot) await cog.initialize() except ImportError: raise CogLoadError( "You need `crossbar`: https://pypi.org/project/crossbar") else: bot.add_cog(cog)
async def setup(bot: Red): if bot.get_cog("DamnDog"): print("DamnDog already loaded, attempting to unload first...") bot.remove_cog("DamnDog") await bot.remove_loaded_package("DamnDog") bot.unload_extension("DamnDog") n = DamnDog(bot) bot.add_cog(n)
async def setup(bot: Red) -> None: global old_uptime old_uptime = bot.get_command("uptime") if old_uptime: bot.remove_command(old_uptime.name) cog = BetterUptime(bot) await cog.async_init() await out_of_date_check("betteruptime", cog.__version__) bot.add_cog(cog)
async def setup(bot: Red): for cog in INCOMPATIBLE_COGS: if cog in bot.cogs: raise CogLoadError(f"Cog {cog} is incompatible with this cog.") cog = CaseInsensitive(bot) await out_of_date_check("caseinsensitive", cog.__version__) cog.plug_core() cog.plug_alias() bot.add_cog(cog)
async def setup(bot: Red): if bot.get_cog("OnJoin"): LOG.warning("OnJoin already loaded, attempting to unload first...") bot.remove_cog("OnJoin") await bot.remove_loaded_package("OnJoin") bot.unload_extension("OnJoin") n = OnJoin(bot) bot.add_listener(n.voice_state_update, "on_voice_state_update") bot.add_cog(n)
async def setup(bot: Red) -> None: global old_ping old_ping = bot.get_command("ping") if old_ping: bot.remove_command(old_ping.name) cog = AnotherPingCog(bot) await cog.async_init() await out_of_date_check("anotherpingcog", cog.__version__) bot.add_cog(cog)
async def setup(bot: Red) -> None: await validate_tagscriptengine(bot, tse_version) for cog_name, module_name, tag_name in conflicting_cogs: if bot.get_cog(cog_name): raise CogLoadError( f"This cog conflicts with {cog_name} and both cannot be loaded at the same time. " f"After unloading `{module_name}`, you can migrate {tag_name} to tags with `[p]migrate{module_name}`." ) tags = Tags(bot) bot.add_cog(tags)
def load_or_reload(bot: Red, load: Type[commands.Cog], *args, **kwargs): name = load.__name__ if name not in loaded or loaded[name] is not bot.get_cog(name): old = bot.cogs.get(name) if old: log.debug("Unloading previously loaded version of internal cog %r", name) bot.remove_cog(name) log.info("Loading internal cog %r", name) loaded[name] = load = load(bot, *args, **kwargs) if old and hasattr(load, "sl_reload_hook"): load.sl_reload_hook(old) bot.add_cog(load)
async def setup(bot: Red): try: setup_cog(bot, "Quotes", require_version="0.0.2a0") except TypeError: from redbot.core.errors import CogLoadError raise CogLoadError( "Your bot is running an outdated version of the shared library this" " cog depends on. You can resolve this issue by either running" "`[p]swiftlibs reload`, or by restarting your bot.") from quotes.quotes import Quotes bot.add_cog(Quotes(bot))
async def setup(bot: Red): try: setup_cog(bot, "RNDActivity", require_version="0.0.3a0") except TypeError: from redbot.core.errors import CogLoadError raise CogLoadError( "Your bot is running an outdated version of the shared library this" " cog depends on. You can resolve this issue by either running" "`[p]swiftlibs reload`, or by restarting your bot.") try_import("babel") from rndactivity.rndactivity import RNDActivity bot.add_cog(RNDActivity(bot))
async def setup(bot: Red): # Replace invite command. global old_invite old_invite = bot.get_command("invite") if old_invite: bot.remove_command(old_invite.name) # Replace info command. global old_info old_info = bot.get_command("info") if old_info: bot.remove_command(old_info.name) brawlcord = Brawlcord(bot) await brawlcord.initialize() bot.add_cog(brawlcord)
def setup(bot: Red): cog = Captcher(bot) bot.add_cog(cog) the_grand_final = ( "Hi, captain' speaking. I am the creator of Captcher. This cog is now outdated and " "officialy put in trash, meaning Captch**er** won't receive any new update.\n\nActually, " "you may be confused on this decision, but it happened because I decided to redo this " "cog from scratch, (From nothing) and so appear my new cog, **Captcha**, the " "BetterCaptcher of Captcher.\nThis cog will, of course, still work, but for the price " "of no support anymore, this ~beautiful~ message everytime you load this cog and you " "restart your bot, and no more update.\n\nI don't really know why you would do this, " "but feel free to. Captch**er** is made on very bad code, and is still in beta, this " "is just the worst idea to keep it.\n\nAnyway, if you decide to change to Captcha, I'm " "sad to announce you that I decided not to convert your data from Captcher, you will " "have to setup everything again... yep.\n\nThanks for the person who contribued to the " "creation of Captcher and that helped me find the bugs." ) bot.loop.create_task(bot.send_to_owners(the_grand_final))
async def setup(cls, bot: Red): config = Config.get_conf(None, 78631113035100160, cog_name="ModOnlyMode") config.register_guild(active=False, exclusions=[]) all_guild_data = await config.all_guilds() cache = SnowflakeList(()) exclusion_cache: Dict[str, SnowflakeList] = defaultdict( lambda: SnowflakeList(()) ) for guild_id, guild_data in all_guild_data.items(): if guild_data.get("active", False): cache.add(guild_id) for exclusion in guild_data.get("exclusions", []): exclusion_cache[exclusion].add(guild_id) cog = cls(bot, config, cache, exclusion_cache) bot.add_cog(cog)
async def setup(bot: Red): try: setup_cog(bot, "TimedMute", require_version="0.0.2a0") except TypeError: raise CogLoadError( "Your bot is running an outdated version of the shared library this" " cog depends on. You can resolve this issue by either running" "`[p]swiftlibs reload`, or by restarting your bot." ) try_import("babel") from timedmute.shared import translate if "TimedRole" not in bot.cogs: raise CogLoadError(translate("requires_timedrole")) from timedmute.timedmute import TimedMute bot.add_cog(TimedMute(bot))
async def setup(bot: Red): try: setup_cog(bot, "MiscTools", require_version="0.0.3a0") except TypeError: from redbot.core.errors import CogLoadError raise CogLoadError( "Your bot is running an outdated version of the shared library this" " cog depends on. You can resolve this issue by either running" "`[p]swiftlibs reload`, or by restarting your bot.") try_import("babel", "tzlocal") from misctools.misctools import MiscTools cog = MiscTools(bot) bot.add_cog(cog) try: await cog.bootstrap() except Exception: bot.remove_cog("MiscTools") raise
def setup(bot: Red): bot.add_cog(Memento(bot))
def setup(bot: Red): cog = Captcha(bot) bot.add_cog(cog) # noinspection PyProtectedMember bot.loop.create_task(cog._initialize())
async def setup(bot: Red) -> None: cog = CustomHelp(bot) bot.add_cog(cog) # is this too costly? should I use a task rather? await cog._setup()
def setup(bot: Red): bot.add_cog(CatFact())
def main(): description = "Bot Base - Version {}".format(__version__) cli_flags = parse_cli_flags(sys.argv[1:]) if cli_flags.list_instances: list_instances() elif cli_flags.version: print(description) sys.exit(0) elif not cli_flags.instance_name and not cli_flags.no_instance: print("Error: No instance name was provided!") sys.exit(1) if cli_flags.no_instance: print( "\033[1m" "Warning: The data will be placed in a temporary folder and removed on next system " "reboot." "\033[0m") cli_flags.instance_name = "temporary_red" create_temp_config() load_basic_configuration(cli_flags.instance_name) log = init_loggers(cli_flags) loop = asyncio.get_event_loop() red = Red(cli_flags=cli_flags, description=description, pm_help=None) init_global_checks(red) init_events(red, cli_flags) loop.run_until_complete(red.cog_mgr.initialize()) red.add_cog(Core(red)) red.add_cog(CogManagerUI()) if cli_flags.dev: red.add_cog(Dev()) # noinspection PyProtectedMember modlog._init() # noinspection PyProtectedMember bank._init() if os.name == "posix": loop.add_signal_handler( SIGTERM, lambda: asyncio.ensure_future(sigterm_handler(red, log))) tmp_data = {} loop.run_until_complete(_get_prefix_and_token(red, tmp_data)) token = os.environ.get("RED_TOKEN", tmp_data["token"]) if cli_flags.token: token = cli_flags.token prefix = cli_flags.prefix or tmp_data["prefix"] if not (token and prefix): if cli_flags.no_prompt is False: new_token = interactive_config(red, token_set=bool(token), prefix_set=bool(prefix)) if new_token: token = new_token else: log.critical("Token and prefix must be set in order to login.") sys.exit(1) loop.run_until_complete(_get_prefix_and_token(red, tmp_data)) if cli_flags.dry_run: loop.run_until_complete(red.http.close()) sys.exit(0) try: loop.run_until_complete(red.start(token, bot=True)) except discord.LoginFailure: log.critical("This token doesn't seem to be valid.") db_token = loop.run_until_complete(red.db.token()) if db_token and not cli_flags.no_prompt: print("\nDo you want to reset the token? (y/n)") if confirm("> "): loop.run_until_complete(red.db.token.set("")) print("Token has been reset.") except KeyboardInterrupt: log.info("Keyboard interrupt detected. Quitting...") loop.run_until_complete(red.logout()) red._shutdown_mode = ExitCodes.SHUTDOWN except Exception as e: log.critical("Fatal exception", exc_info=e) loop.run_until_complete(red.logout()) finally: pending = asyncio.Task.all_tasks(loop=red.loop) gathered = asyncio.gather(*pending, loop=red.loop, return_exceptions=True) gathered.cancel() try: loop.run_until_complete(red.rpc.close()) except AttributeError: pass sys.exit(red._shutdown_mode.value)
def setup(bot: Red): bot.add_cog(Mod(bot))
def setup(bot: Red): bot.add_cog(Alias(bot))
def setup(bot: Red): bot.add_cog(Welcome(bot))
def setup(bot: Red): bot.add_cog(Filter(bot))
def setup(bot: Red): bot.add_cog(Reminder(bot))
async def setup(bot: Red) -> None: role_utils = RoleUtils(bot) bot.add_cog(role_utils) await role_utils.initialize()
def setup(bot: Red): bot.add_cog(Reports(bot))
def setup(bot: Red): bot.add_cog(Translator(bot))
def setup(bot: Red): bot.add_cog(ReactRoles(bot))