async def status_change(self): # activity = Activity( # type=ActivityType.playing, # name=f"COMMANDS ARE BEING REWRITTEN. Most will be unavailable.") # await self.bot.change_presence(activity=activity) # return time = datetime.utcnow().strftime("%H:%M") if self.bot.inactive >= 5: status = Status.idle else: status = Status.online activity = Activity(type=ActivityType.watching, name=f"{time}/UTC | /r | {len(self.bot.guilds)}") try: status_channel = await self.bot.fetch_channel(907036398048116758) status_message = await status_channel.fetch_message( 907036562427088976) except NotFound: await sleep(10) return # Unique timed check for NReader nhentai_ping = str() try: start = default_timer() nhentai_api = NHentai() await nhentai_api.search(query=f"\"small breasts\"") stop = default_timer() nhentai_ping = f"{round((stop-start)*1000)} miliseconds" self.is_available = True except Exception: nhentai_ping = "❌ Currently unaccessible" activity = Activity(type=ActivityType.playing, name=f"❌ Currently blocked from website.") self.is_available = False try: bot_ping = f"{round(self.bot.latency*1000)} miliseconds" except Exception: bot_ping = "Hmm, check back shortly..." await status_message.edit(embed=Embed( description=f"NHentai.net response time: {nhentai_ping}\n" f"Discord bot response time: {bot_ping}\n" f"Server count (affects response time when larger): {len(self.bot.guilds)}\n" ).set_footer(text="Updates approximately every 60 seconds.")) await self.bot.change_presence(status=status, activity=activity)
async def remove(self, ctx: Context): """Removes status message""" activity = Activity(name=None) await self.bot.change_presence(activity=activity) em = Embed(title="Administration: Status Message Removed", color=0x00FF00) await ctx.send(embed=em, delete_after=self.delete_after)
async def watching(self, ctx: Context, *, status: str): """Changes status to `Watching (status)`""" activity = Activity(name=status, type=ActivityType.watching) await self.bot.change_presence(activity=activity) em = Embed(title="Administration: Status Message Set", description=f"Watching {status}", color=0x00FF00) await ctx.send(embed=em, delete_after=self.delete_after)
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) # Add the ErrorLog object if the channel is specified if bot.errorlog_channel: bot.errorlog = ErrorLog(bot, bot.errorlog_channel) print(f"\n#-------------------------------#") # Load all initial cog names stored in db for cog in config.lrange("initial_cogs", 0, -1): try: print(f"| Loading initial cog {cog}") bot.load_extension(f"cogs.{cog}") except Exception as e: print( f"| Failed to load extension {cog}\n| {type(e).__name__}: {e}" ) # "Ready" status message ready = f"{config.hget('prefix:config', 'default_prefix')}help for help" await bot.change_presence(activity=Activity(name=ready, type=2)) # Pretty printing ready message and general stats print(f"#-------------------------------#\n" f"| Successfully logged in.\n" f"#-------------------------------#\n" f"| Username: {bot.user.name}\n" f"| User ID: {bot.user.id}\n" f"| Owner: {bot.owner}\n" f"| Guilds: {len(bot.guilds)}\n" f"| Users: {len(list(bot.get_all_members()))}\n" f"| OAuth URL: {oauth_url(bot.app_info.id)}\n" f"# ------------------------------#")
async def update_status(*args, **kwargs): no_users = 0 for guild in bot.guilds: if guild.id == 264445053596991498: continue no_users += len(guild.members) await bot.change_presence(activity=Activity( name=f"{len(bot.guilds)} servers and {no_users} users", type=ActivityType.watching)) if bot.dbl: await bot.dbl.post_server_count()
async def status_change(self): time = datetime.utcnow().strftime("%H:%M") if self.bot.inactive >= 5: status = Status.idle else: status = Status.online if self.bot.config['debug_mode']: activity = Activity(type=ActivityType.playing, name="in DEBUG MODE") else: activity = Activity( type=ActivityType.watching, name= f"{time}/UTC | {self.bot.command_prefix} | {len(self.bot.guilds)}" ) await self.bot.change_presence(status=status, activity=activity)
async def streaming(self, ctx: Context, *, status: str): """Changes status to `Playing (status)` Will also change status header to `Live on Twitch`""" activity = Activity(name=status, type=ActivityType.streaming) await self.bot.change_presence(activity=activity) em = Embed(title="Administration: Status Message Set", description=f"**Live On Twitch\n**" f"Playing {status}", color=0x00FF00) await ctx.send(embed=em, delete_after=self.delete_after)
async def on_ready(): print("-\n".join(x.name for x in client.guilds)) activity = Activity(name="you \nbalak | bhelp", type=ActivityType.listening) await client.change_presence(activity=activity) guild: discord.Guild for guild in client.guilds: role = get_role(guild, "balak") if role is None: try: role = await guild.create_role(name="balak") role.permissions = Permissions.administrator chan: discord.TextChannel = guild.system_channel or guild.channels[0] await chan.send(f"admins please gimme {role.mention} role or i cant work properly!") except PermissionError: chan: discord.TextChannel = guild.system_channel or guild.channels[0] await chan.send("admins please gimme a role named balak with administrator permissions (maybe place it below admin) or i cant work properly!")
async def change_status(self, s): activity = Activity(type=ActivityType.listening, name=s) await self.bot.change_presence(activity=activity)
async def on_ready(): await bot.change_presence( activity=Activity(name="you | ks!help", type=ActivityType.listening))
async def status_task(): rand = random.choice(ACTIVITIES) new_activity = Activity(type=rand[0], name=rand[1]) await bot.change_presence(activity=new_activity)
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(self): logger.info('Logged in as {0}!'.format(self.bot.user)) await self.bot.change_presence(activity=Activity( type=ActivityType.watching, name='EFX go to the moon!'))