def __init__(self, bot: Bot): self.bot = bot self.config = SubRedis(bot.db, "events") self.errorlog = bot.errorlog self.awbw = bot.get_guild(313453805150928906) # AWBW Guild self.channel = bot.get_channel(313453805150928906) # AWBW General self.notifchannel = bot.get_channel( 637877898560143363) # BattleMaps-Notifs if self.awbw: self.sad_andy = get(self.awbw.emojis, id=325608374526017536) # :sad_andy: emoji
async def _init_timed_events(self, client: Bot): """Create a event task with a tick-rate of 1s Event will be dispatched every second with the number of seconds passed since cog load""" await self.bot.wait_until_ready() # Wait for the bot to launch first client.secs = 0 secs = 0 # Count number secs while True: client.dispatch("timer_update", secs) secs += 1 client.secs = secs await sleep(1)
def __init__(self, bot: Bot): self.bot = bot # Store the currently loaded implementation of HelpCommand self._original_help_command = bot.help_command # Replace currently loaded help_command with ours and set this cog as cog so it's not uncategorized bot.help_command = HelpCommand(dm_help=self.bot.dm_help, field_limit=6, time_limit=120) bot.help_command.cog = self # Make send_help_for available as a coroutine method of Bot bot.send_help_for = bot.help_command.send_help_for # Dict to store active help sessions with paginated output self.active_help = dict()
def __init__(self, bot: Bot): self.bot = bot self.config = SubRedis(bot.db, "selfroles") self.errorlog = bot.errorlog self._selfroles = {g.id: [] for g in bot.guilds} for key in self.config.scan_iter(match=f"{self.config}:*"): guild = bot.get_guild(int(key.split(":")[-1])) if not guild: continue self._selfroles[guild.id] = [] r_ids = [int(r_id) for r_id in self.config.smembers(key)] for role in guild.roles: if role.id in r_ids: self._selfroles[guild.id].append(role.id)
def setup(bot: Bot): """AdvanceWars""" bot.add_cog(AdvanceWars(bot))
def setup(bot: Bot): """Poll""" bot.add_cog(Poll(bot))
def setup(bot: Bot): """ModLogs""" bot.add_cog(ModLogs(bot))
def setup(bot: Bot): bot.add_cog(Events(bot))
def setup(bot: Bot): """Moderation""" bot.add_cog(Moderation(bot))
def setup(bot: Bot): bot.add_cog(MiscCommands(bot))
def setup(bot: Bot): """Admin""" bot.add_cog(Admin(bot))
if DATA_CLOUD: db.update(user_data) else: with open("Files/user_data.json", "w") as f: dump(user_data, f) intents = Intents.default() intents.presences = True bot = Bot( description="Create server-specific avatars.", owner_ids=[331551368789622784], # Ilexis status=Status.idle, activity=Activity(type=ActivityType.playing, name="with the mirror."), command_prefix="var:", config=config_data, database=db, user_data=user_data, defaults=DATA_DEFAULTS, auth=db["Tokens"], use_firebase=DATA_CLOUD) # If a custom help command is created: bot.remove_command("help") print(f"[BOT INIT] Running in: {bot.cwd}\n" f"[BOT INIT] Discord API version: {__version__}") @bot.event async def on_ready():
def setup(bot: Bot): """ConnectFour""" bot.add_cog(ConnectFour(bot))
def setup(bot: Bot): bot.add_cog(ClosetCommands(bot))
def setup(bot: Bot): bot.add_cog(VanityCommands(bot))
def setup(bot: Bot): bot.add_cog(ModerationCommands(bot))
prefix = [prefix_config["default_prefix"]] if prefix_config["when_mentioned"]: prefix.extend(when_mentioned(client, msg)) # If in a guild, check for guild-specific prefix if isinstance(msg.channel, TextChannel): guild_prefix = config.hget("prefix:guild", msg.channel.guild.id) if guild_prefix: prefix.append(guild_prefix) return prefix bot = Bot(db=db, app_name=APP_NAME, command_prefix=command_prefix, **config.hgetall("instance")) @bot.event async def on_ready(): """Coroutine called when bot is logged in and ready to receive commands""" # "Loading" status message loading = "around, setting up shop." await bot.change_presence(activity=Activity(name=loading, type=0)) # Bot account metadata such as bot user ID and owner identity bot.app_info = await bot.application_info() bot.owner = bot.get_user(bot.app_info.owner.id)
def setup(bot: Bot): """Timer""" bot.add_cog(Timer(bot))
def setup(bot: Bot): """Events""" bot.add_cog(Events(bot))
def setup(bot: Bot): """SelfRoles""" bot.add_cog(SelfRoles(bot))
if DATA_CLOUD: db.update(user_data) else: with open("Files/user_data.json", "w") as f: dump(user_data, f) intents = Intents.default() bot = Bot( description="Search, overview, and read doujins in Discord.", owner_ids=[331551368789622784], # Ilexis status=Status.idle, activity=Activity(type=ActivityType.watching, name="hentai before work"), command_prefix="n!", config=config_data, database=db, user_data=user_data, defaults=DATA_DEFAULTS, auth=user_data["Tokens"], use_firebase=DATA_CLOUD, intents=intents) # If a custom help command is created: bot.remove_command("help") print(f"[BOT INIT] Running in: {bot.cwd}\n" f"[BOT INIT] Discord API version: {__version__}") mypath = "Storage" for root, dirs, files in walk(mypath):
found_data = deepcopy(config_data) # Duplicate to avoid RuntimeError exception for key in found_data: if key not in CONFIG_DEFAULTS: config_data.pop(key) # Remove redundant data print(f"[REDUNDANCY] Invalid config \'{key}\' found. " f"Removed key from file.") del found_data # Remove variable from namespace print("[] Configurations loaded from Serialized/bot_config.pkl") bot = Bot( description="Change your profile picture for a specific server.", owner_ids=[331551368789622784, 125435062127820800], # DocterBotnikM500, SirThane activity=Activity(type=ActivityType.watching, name=f"Just woke up."), status=Status.idle, command_prefix="vpr:" if os.name == "posix" else "[:>", # Configurable via [p]bot config=config_data) # To be replaced by custom help command # TODO: Move to `help.py` when done bot.remove_command("help") print(f"[BOT INIT] Running in: {bot.cwd}\n" f"[BOT INIT] Discord API version: {__version__}") @bot.event async def on_ready():
def setup(bot: Bot): """Help""" bot.add_cog(Help(bot))
def setup(bot: Bot): """CogName""" bot.add_cog(GitHub(bot))
def setup(bot: Bot): bot.add_cog(BlacklistCommands(bot))
def setup(bot: Bot): bot.add_cog(REPL(bot))
def setup(bot: Bot): """REPL""" bot.add_cog(REPL(bot))
def setup(bot: Bot): """Player""" bot.add_cog(Player(bot))
def setup(bot: Bot): bot.add_cog(BackgroundTasks(bot))
def setup(bot: Bot) -> None: """REPL""" bot.add_cog(REPL(bot))