我们从Python开源项目中,提取了以下30个代码示例,用于说明如何使用discord.__version__()。
def on_ready(self): """ A listener for the event in which the bot is ready to work. """ lib.log("") lib.log("Using discord.py version: " + discord.__version__) lib.log("Logged in as :") lib.log("\t" + self.bot.user.name) lib.log("\t" + self.bot.user.id) lib.log("") await self.bot.update_status() message = "**[{}]** {}"\ .format(config.get_config().get_str('version'), config.get_config().get_str('startup_msg')) for server in self.bot.servers: await self.bot.send_message(server, message)
def about(self, ctx): '''About me''' from clients import application_info changes = os.popen(r'git show -s HEAD~3..HEAD --format="[`%h`](https://github.com/Harmon758/Harmonbot/commit/%H) %s (%cr)"').read().strip() embed = discord.Embed(title = "About Me", color = clients.bot_color) embed.description = "[Changelog (Harmonbot Server)]({})\n[Invite Link]({})".format(clients.changelog, discord.utils.oauth_url(application_info.id)) # avatar = ctx.message.author.avatar_url or ctx.message.author.default_avatar_url # embed.set_author(name = ctx.message.author.display_name, icon_url = avatar) avatar = self.bot.user.avatar_url or self.bot.user.default_avatar_url # embed.set_thumbnail(url = avatar) embed.set_author(name = "Harmonbot (Discord ID: {})".format(self.bot.user.id), icon_url = avatar) if changes: embed.add_field(name = "Latest Changes:", value = changes, inline = False) embed.add_field(name = "Created on:", value = "February 10th, 2016") embed.add_field(name = "Version", value = clients.version) embed.add_field(name = "Library", value = "[discord.py](https://github.com/Rapptz/discord.py) v{0}\n([Python](https://www.python.org/) v{1.major}.{1.minor}.{1.micro})".format(discord.__version__, sys.version_info)) me = discord.utils.get(self.bot.get_all_members(), id = clients.owner_id) avatar = me.default_avatar_url if not me.avatar else me.avatar_url embed.set_footer(text = "Developer/Owner: {0} (Discord ID: {0.id})".format(me), icon_url = avatar) await self.bot.reply("", embed = embed) await self.bot.say("Changelog (Harmonbot Server): {}".format(clients.changelog))
def on_ready(self): logging.info(f'Logged in \nUsername: {self.user.name}\nID: {self.user.id}\nAPI Version: {discord.__version__}') gameplayed = config.MAIN.get("gameplayed", "Yuri is Love") if gameplayed: game = discord.Game(name=gameplayed) await self.change_presence(game=game) avatar_file_name = config.MAIN.get("avatarfile") if avatar_file_name: with open(avatar_file_name, "rb") as f: avatar = f.read() await self.edit_profile(avatar=avatar) if self.first_run: self.first_run = False self.get_forbidden_list() self.get_startswith() self.fill_member_list() self.skype.discord = self for k, v in list(config.ch.items()): if v.isdigit(): config.ch[k] = self.get_channel(v) self.run_loop() # TODO Add embed support
def about(self, ctx): """Shows some info about the bot.""" bot = ctx.bot description = 'This page contains some basic but useful info.' useful_links = ( f'[Click here to go to the support server!]({bot.support_invite})\n' f'[Click me to invite me to your server!]({bot.invite_url})\n' "[Check the code out here (it's fire!)](https://github.com/Ikusaba-san/Chiaki-Nanami)\n" ) embed = (discord.Embed(colour=bot.colour) .set_thumbnail(url=bot.user.avatar_url) .set_author(name=str(bot.user)) .add_field(name='Creator', value=bot.creator) .add_field(name='Servers', value=bot.guild_count) .add_field(name='Python', value=platform.python_version()) .add_field(name='Library', value=DISCORD_PY_LIB) .add_field(name='Useful links', value=useful_links, inline=False) .set_footer(text=f'Chiaki is on Version {bot.__version__} <3') ) await ctx.send(embed=embed)
def on_ready(self): """ Called once a connection has been established """ log.ready("Running discord.py version: " + discord.__version__) log.ready("Connected to Discord!") log.info("Logged in as {0.name}.{0.discriminator} ({0.id})" .format(self.user)) log.info("Prefix: " + self.config.prefix) log.info("SelfBot: " + ['true', 'false'][self.config.useToken]) self.loop.create_task(self.saveloop()) log.ready("Autosave coroutine running...") # self.loop.create_task(self.banloop()) log.ready("Auto-unban coroutine running...") if self.config.get("mysql") is not None: self.loop.create_task(self.askPatchLoop()) log.ready("MOTD system running...") pass else: log.warn("No mysql configuration in config.yaml," + "motd features are disabled") return
def info(self, ctx): """ Information about GAF Bot """ with ctx.channel.typing(): embed = discord.Embed(title="Invite me to your server!", colour=discord.Colour.gold(), url="https://discordapp.com/oauth2/authorize?&client_id=173708503796416512&scope=bot&permissions=8", description=self.bot.description, timestamp=datetime.datetime.utcfromtimestamp(1493993514)) embed.set_thumbnail(url=ctx.author.avatar_url) embed.set_author(name="GAF Bot", url="https://github.com/DiNitride/GAFBot") embed.add_field(name="Source Code", value="https://github.com/DiNitride/GAFBot") embed.add_field(name="Author", value="GAF Bot is written and maintained by DiNitride#7899") embed.add_field(name="Discord.py Version", value=discord.__version__) embed.add_field(name="The Never Ending GAF", value="GAF Bot is the bot of the awful community known as " "The Never Ending GAF, which you can find out about at " "http://www.neverendinggaf.com") await ctx.send(embed=embed)
def on_ready(self): """A `bot` event triggered when the bot authentication has been successful. Notifies console when `bot` is ready.""" self.main_server = self.bot.get_guild(212982046992105473) self.whitelisted_servers = [ self.main_server, # a11discord self.bot.get_guild(173152280634327040), #avinchtest self.bot.get_guild(338732924893659137) #cassbotpy ] self.backup_server = self.bot.get_guild(349652162948759555) self.mod_log = discord.utils.get(self.main_server.channels, name="mod-log") self.bot.session = aiohttp.ClientSession() print(textwrap.dedent(f""" ===================================== Discord Version: {discord.__version__} Username: {self.bot.user.name} User ID: {self.bot.user.id} Started: {datetime.datetime.utcnow()} UTC Opus: {'Loaded' if self.load_opus_lib() else 'Failed'} ====================================="""))
def on_ready(): print('\nLogin Details:') print('---------------------') print('Logged in as:') print(client.user.name) print('Bot User ID:') print(client.user.id) print('---------------------\n') print('---------------------------------------') print('Running discord.py version ' + discord.__version__) print('---------------------------------------\n') print('STATUS: Finished Loading!') print('-------------------------\n') print('-----------------------------------------') print('Authors: AXAz0r, Awakening, Battlemuffins') print('Bot Version: Beta 0.12b') print('Build Date: 9. August 2016.') print('-----------------------------------------\n')
def info(self, ctx): await ctx.send(f'```{self.bot.description}\n\nFramework: discord.py {discord.__version__}\nSource: https://github.com/Run1e/AceBot```')
def on_ready(): await bot.user.edit(username=bot.info['nick']) await bot.change_presence(game=discord.Game(name=bot.info['status'], type=1)) if __name__ == '__main__': print(f'Logged in as: {bot.user.name} - {bot.user.id}\nVersion: {discord.__version__}\n') for extension in extensions: print(f'Loading extension: {extension}') bot.load_extension(extension) print(f'\nConnected to {len(bot.guilds)} servers:') print('\n'.join(f'{guild.name} - {guild.id}' for guild in bot.guilds))
def info(self, ctx): """Show some of the more statistical information about me. This information includes the current version(s), number of commands, amount of servers, channels, users, uptime, and average websocket ping. **Usage:** `g_info` **Permission:** User""" commands = len(self.bot.commands) cogs = len(self.bot.cogs) version = discord.__version__ before = time.monotonic() await (await self.bot.ws.ping()) after = time.monotonic() ping = (after - before) * 1000 pversion = platform.python_version() server_count = 0 member_count = 0 channel_count = 0 for server in self.bot.guilds: server_count += 1 for channel in server.channels: channel_count += 1 for member in server.members: member_count += 1 await ctx.send("""```prolog =========[ Bot Information ]========= Commands : {0} Cogs : {1} Version : {2} DiscordPY Version : {3} Python Version : {4} Websocket Ping : {5:.0f}ms Uptime : {6} =========[ Guild Information ]========= Guilds : {7} Users : {8} Channels : {9} Host : heroku```""".format(commands, cogs, self.bot.version, version, pversion, ping, self.get_bot_uptime(), server_count, member_count, channel_count))
def on_ready(): print('Inkxbot is logged in and online!') print("discord.py version is " + discord.__version__) print('--------------------------------') if not hasattr(bot, 'uptime'): bot.uptime = datetime.datetime.utcnow() bot.task = bot.loop.create_task(background_task())
def on_ready(): print('Logged in') print('Name : {}'.format(bot.user.name)) print('ID : {}'.format(bot.user.id)) print(discord.__version__)
def info(self, ctx): """Display bot info, e.g. library versions.""" embed = discord.Embed() embed.description = ctx.bot.description embed.set_thumbnail(url=ctx.bot.user.avatar_url_as(format="png", size=128)) if k2: embed.add_field(name="Version", value=k2.version) ainfo = await ctx.bot.application_info() owner = str(ainfo.owner) embed.add_field(name="Owner", value=owner) embed.add_field(name="# of commands", value=len(ctx.bot.commands)) if ctx.guild and ctx.bot.shard_count > 1: embed.add_field(name="Shard", value=f"{ctx.guild.shard_id+1} of {ctx.bot.shard_count}") num_guilds = len(ctx.bot.guilds) num_users = sum(not member.bot for member in ctx.bot.get_all_members()) embed.add_field(name="Serving", value=f"{num_users} people in {num_guilds} guilds") embed.add_field(name="Python", value="{0}.{1}.{2}".format(*sys.version_info)) embed.add_field(name="discord.py", value=discord.__version__) usage_memory = round(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1000, 2) embed.add_field(name="Cookies eaten", value=f"{usage_memory} megabites") if k2: embed.add_field(name="Github", value=k2.url, inline=False) await ctx.send(embed=embed)
def get_shard_count(self): r = requests.get(BOT_ENDPOINT, headers={ "Authorization": "Bot {}".format(self.token), "User-Agent": 'DiscordBot (https://github.com/Rapptz/discord.py {0}) Python/{1[0]}.{1[1]} requests/{2}'.format( discord.__version__, sys.version_info, requests.__version__) }) if r.status_code == 200: return r.json()['shards']+1 else: return None
def botinformation(cmd, message, args): version_data = cmd.bot.info.get_version().raw author_data = cmd.bot.info.get_authors().raw sigma_image = 'https://i.imgur.com/mGyqMe1.png' support_url = 'https://discordapp.com/invite/aEUCHwX' ver_nest = version_data["version"] full_version = f'{ver_nest["major"]}.{ver_nest["minor"]}.{ver_nest["patch"]}' if version_data['beta']: full_version += ' Beta' sigma_title = f'Apex Sigma: v{full_version} {version_data["codename"]}' env_text = f'Language: **Python {sys.version.split()[0]}**' env_text += f'\nLibrary: **discord.py** {discord.__version__}' env_text += f'\nPlatform: **{sys.platform.upper()}**' auth_text = '' for author in author_data: auth = discord.utils.find(lambda x: x.id == author['id'], cmd.bot.get_all_members()) if auth: auth_text += f'\n**{auth.name}**#{auth.discriminator}' else: auth_text += f'\n**{author["name"]}**#{author["discriminator"]}' response = discord.Embed(color=0x1B6F5F, timestamp=arrow.get(version_data['build_date']).datetime) response.set_author(name=sigma_title, icon_url=sigma_image, url=support_url) response.add_field(name='Authors', value=auth_text) response.add_field(name='Environment', value=env_text) response.set_footer(text=f'Last updated {arrow.get(version_data["build_date"]).humanize()}') await message.channel.send(embed=response)
def stats(bot, log=None): tmp = [] permed_ids = [] for ownr in permitted_id: permed_ids.append(str(ownr)) authors = userlist(bot.authors) donor_count = len(bot.donors) with open('VERSION') as version_file: content = yaml.safe_load(version_file) version = content['version'] build_date = datetime.datetime.fromtimestamp(content['build_date']).strftime('%B %d, %Y') v_major = version['major'] v_minor = version['minor'] v_patch = version['patch'] codename = content['codename'] beta_state = content['beta'] v_full = str(v_major) + '.' + str(v_minor) + '.' + str(v_patch) version_text = '' if beta_state: version_text += 'Beta ' version_text += v_full + ' Codename ' + codename tmp.append(multi('Logged In As: \"' + bot.user.name + '\"', log)) tmp.append(multi(f'Bot User ID: {bot.user.id}', log)) tmp.append(multi('Python version: ' + sys.version.split(' ')[0], log)) tmp.append(multi('discord.py version: ' + discord.__version__, log)) tmp.append(multi('Authors: {:s}'.format(authors), log)) tmp.append(multi('Donors: ' + str(donor_count), log)) tmp.append(multi('Bot Version: ' + version_text, log)) tmp.append(multi('Build Date: ' + build_date, log)) tmp.append(multi('Connected to [ {:d} ] servers'.format(len(bot.guilds)), log)) tmp.append(multi('Serving [ {:d} ] users'.format(len(list(bot.get_all_members()))), log)) tmp.append(multi(f'Permitted IDs: {", ".join(permed_ids)}', log)) return tmp
def info(self, ctx): """Affiches des informations sur le bot""" text = open('texts/info.md').read() os_info = str(platform.system()) + " / " + str(platform.release()) em = discord.Embed(title='Informations sur TuxBot', description=text.format(os_info, platform.python_version(), socket.gethostname(), discord.__version__), colour=0x89C4F9) em.set_footer(text=os.getcwd() + "/bot.py") await ctx.send(embed=em) ## HELP PLZ ##
def on_ready(): print('######################################################') print('# Nya Chan #') print('######################################################') print('Discord.py version : ' + discord.__version__) print('Bot User : ' + str(bot.user)) app_infos = await bot.application_info() bot.owner_id = app_infos.owner.id print('Bot Owner : ' + str(bot.owner_id)) url = discord.utils.oauth_url(app_infos.id) print('Oauth URL : ' + str(url))
def on_ready(): print('Logged in as:') print('Username: ' + bot.user.name) print('ID: ' + bot.user.id) print('Discord Version: ' + discord.__version__) print('Author: Mirai') if not hasattr(bot, 'uptime'): bot.uptime = datetime.datetime.utcnow()
def on_ready(): print("discord.py version: {}".format(discord.__version__)) print('Running script as: {}#{}({})'.format(bot.user.name, bot.user.discriminator, bot.user.id)) print('------------------------------------------------------------------') if not hasattr(bot, 'game_name'): bot.game_name = None if not hasattr(bot, 'status'): bot.status = discord.Status.online await bot.change_presence(status=bot.status) # reset these to empty list bot.log_servers = [] bot.log_private_channels_list = [] if bot.log_all_messages_on_start: print("Beginning to dump previous messages to log...") log.info("====================== Dumping Previous Messages ======================") # first log all servers and channels in servers for server in bot.servers: for channel in server.channels: permissions = channel.permissions_for(server.get_member(bot.user.id)) if all(getattr(permissions, perm, None) == True for perm in ["read_messages", "read_message_history"]): async for message in bot.logs_from(channel, limit=bot.message_channel_max): log_message(message) # now the same for PrivateChannels for channel in bot.private_channels: async for message in bot.logs_from(channel, limit=bot.message_channel_max): log_message(message) log.info("====================== End Previous Message Dump ======================") print("Finished dumping previous messages!")
def botinformation(cmd, message, args): version_data = cmd.bot.info.version.raw author_data = cmd.bot.info.authors.raw sigma_image = 'https://i.imgur.com/mGyqMe1.png' support_url = 'https://discordapp.com/invite/aEUCHwX' ver_nest = version_data["version"] full_version = f'{ver_nest["major"]}.{ver_nest["minor"]}.{ver_nest["patch"]}' if version_data['beta']: full_version += ' Beta' sigma_title = f'Apex Sigma: v{full_version} {version_data["codename"]}' env_text = f'Language: **Python {sys.version.split()[0]}**' env_text += f'\nLibrary: **discord.py** {discord.__version__}' env_text += f'\nPlatform: **{sys.platform.upper()}**' auth_text = '' for author in author_data: auth = discord.utils.find(lambda x: x.id == author['id'], cmd.bot.get_all_members()) if auth: auth_text += f'\n**{auth.name}**#{auth.discriminator}' else: auth_text += f'\n**{author["name"]}**#{author["discriminator"]}' response = discord.Embed(color=0x1B6F5F, timestamp=arrow.get(version_data['build_date']).datetime) response.set_author(name=sigma_title, icon_url=sigma_image, url=support_url) response.add_field(name='Authors', value=auth_text) response.add_field(name='Environment', value=env_text) response.set_footer(text=f'Last updated {arrow.get(version_data["build_date"]).humanize()}') await message.channel.send(embed=response)
def version(self, ctx): """Show current josé version""" pyver = '%d.%d.%d' % (sys.version_info[:3]) head_id = await shell('git rev-parse --short HEAD') branch = await shell('git rev-parse --abbrev-ref HEAD') await ctx.send(f'`José v{self.JOSE_VERSION} git:{branch}-{head_id} ' f'py:{pyver} d.py:{discord.__version__}`')
def version(self): """Shows bot's version""" python_version = str(subprocess.check_output("python --version", shell=True))[2:-5] python_version += " " + platform.architecture()[0][:-3] + " bits" commit = str(subprocess.check_output("git rev-parse HEAD", shell=True))[2:-3] os_infos = "Running on " + platform.platform() if platform.machine().endswith("64"): os_infos += " 64 bits" else: os_infos += " 32 bits" await self.bot.say("Python version: " + python_version + "\n" + \ "Commit: " + commit + "\n" + \ "Bot's version: " + self.bot.version + "\n" + \ "Discord's version: " + discord.__version__ + "\n" + \ "Environment: " + os_infos)
def status(self, ctx): '''Infos über den Bot''' timeUp = time.time() - self.bot.startTime hours = timeUp / 3600 minutes = (timeUp / 60) % 60 seconds = timeUp % 60 admin = self.bot.get_user(self.bot.owner_id) users = 0 channel = 0 if len(self.bot.commands_used.items()): commandsChart = sorted(self.bot.commands_used.items(), key=lambda t: t[1], reverse=False) topCommand = commandsChart.pop() commandsInfo = '{} (Top-Command: {} x {})'.format(sum(self.bot.commands_used.values()), topCommand[1], topCommand[0]) else: commandsInfo = str(sum(self.bot.commands_used.values())) for guild in self.bot.guilds: users += len(guild.members) channel += len(guild.channels) embed = discord.Embed(color=ctx.me.top_role.colour) embed.set_footer(text='Dieser Bot ist Open-Source auf GitHub: https://github.com/Der-Eddy/discord_bot') embed.set_thumbnail(url=ctx.me.avatar_url) embed.add_field(name='Admin', value=admin, inline=False) embed.add_field(name='Uptime', value='{0:.0f} Stunden, {1:.0f} Minuten und {2:.0f} Sekunden\n'.format(hours, minutes, seconds), inline=False) embed.add_field(name='Beobachtete Benutzer', value=users, inline=True) embed.add_field(name='Beobachtete Server', value=len(self.bot.guilds), inline=True) embed.add_field(name='Beobachtete Channel', value=channel, inline=True) embed.add_field(name='Ausgeführte Commands', value=commandsInfo, inline=True) embed.add_field(name='Bot Version', value=self.bot.botVersion, inline=True) embed.add_field(name='Discord.py Version', value=discord.__version__, inline=True) embed.add_field(name='Python Version', value=platform.python_version(), inline=True) # embed.add_field(name='Speicher Auslastung', value=f'{round(memory_usage(-1)[0], 3)} MB', inline=True) embed.add_field(name='Betriebssystem', value=f'{platform.system()} {platform.release()} {platform.version()}', inline=False) await ctx.send('**:information_source:** Informationen über diesen Bot:', embed=embed)
def about(self, ctx): """Shows information about the bot.""" git_revision = (await shell('git rev-parse --short HEAD')).strip() if self.maker is None: self.maker = discord.utils.get(self.bot.get_all_members(), id=ctx.bot.cfg["bot"]["owner_id"]) birthday = self.bot.user.created_at.strftime(await ctx._('cmd.about.birthday')) github = ctx.bot.cfg["bot"]["github"] embed = discord.Embed( title=await ctx._('cmd.about.title'), description=await ctx._('cmd.about.description', maker=self.maker) ) rev_link = f'[{git_revision}](https://github.com/{github}/commit/{git_revision})' # git revision embed.add_field(name=await ctx._('cmd.about.fields.git_rev'), value=rev_link) # github repo link embed.add_field( name=await ctx._('cmd.about.fields.github_repo'), value='[{0}](https://www.github.com/{0})'.format(github) ) # birthday embed.add_field(name=await ctx._('cmd.about.fields.birthday'), value=birthday) # who made me? embed.set_author(name=f'{self.maker.name}#{self.maker.discriminator}', icon_url=self.maker.avatar_url) # information about python and discord.py pyversion = platform.python_version() version = discord.__version__ embed.set_footer( text='Python {} \N{EM DASH} Discord.py {}'.format(pyversion, version), icon_url='http://i.imgur.com/v1dAbXi.png' ) await ctx.send(embed=embed)
def stats(cmd, message, args): sigma_avatar = 'https://i.imgur.com/mGyqMe1.png' current_time = arrow.utcnow().timestamp upseconds = current_time - cmd.bot.start_time permed_ids = [] for ownr in permitted_id: permed_ids.append(str(ownr)) uptime = str(datetime.timedelta(seconds=upseconds)) owners = ', '.join(permed_ids) if message.guild: for m in message.guild.members: if m.id in permitted_id: if m.nick: owners = owners.replace(str(m.id), m.nick) else: owners = owners.replace(str(m.id), m.name) full_version = f'{cmd.bot.v_major}.{cmd.bot.v_minor}.{cmd.bot.v_patch}' command_rate = str(cmd.bot.command_count / upseconds) command_rate = command_rate.split('.') command_rate = command_rate[0] + '.' + command_rate[1][:3] message_rate = str(cmd.bot.message_count / upseconds) message_rate = message_rate.split('.') message_rate = message_rate[0] + '.' + message_rate[1][:3] embed = discord.Embed(color=0x1abc9c) embed.set_author(name='Apex Sigma', url='https://auroraproject.xyz/', icon_url=sigma_avatar) embed.add_field(name='Logged In As', value=f'```py\n{cmd.bot.user.name} [{cmd.bot.user.id}]\n```', inline=False) embed.add_field(name='Authors', value=f'```\n{", ".join(cmd.bot.authors)}\n```', inline=False) embed.add_field(name='Bot Version', value=f'```py\n{full_version}\n```') embed.add_field(name='Bot Codename', value=f'```py\n"{cmd.bot.codename}"\n```') if args: if args[0].lower() == 'full': embed.add_field(name='Build Date', value=f'```py\n{cmd.bot.build_date.format("DD-MM-YYYY")}\n```') embed.add_field(name='Environment', value=f'```py\nPython {sys.version.split(" ")[0]}\n```', inline=True) embed.add_field(name='API Wrapper', value=f'```py\nd.py {discord.__version__}\n```', inline=True) embed.add_field(name='Uptime', value=f'```py\n{uptime}\n```', inline=True) embed.add_field(name='Servers', value=f'```py\n{len(cmd.bot.guilds)}\n```') embed.add_field(name='Channels', value=f'```py\n{len(list(cmd.bot.get_all_channels()))}\n```') embed.add_field(name='Users', value=f'```py\n{len(list(cmd.bot.get_all_members()))}\n```') embed.add_field(name='Commands Executed', value=f'```py\n{cmd.bot.command_count} ({command_rate}/s)\n```', inline=True) embed.add_field(name='Messages Processed', value=f'```py\n{cmd.bot.message_count} ({message_rate}/s)\n```', inline=True) embed.add_field(name='Bot Owners', value=f'```\n{owners}\n```', inline=False) await message.channel.send(None, embed=embed)
def info(self): """Shows info about Red""" author_repo = "https://github.com/Twentysix26" red_repo = author_repo + "/Red-DiscordBot" server_url = "https://discord.me/Red-DiscordBot" dpy_repo = "https://github.com/Rapptz/discord.py" python_url = "https://www.python.org/" since = datetime.datetime(2016, 1, 2, 0, 0) days_since = (datetime.datetime.now() - since).days dpy_version = "[{}]({})".format(discord.__version__, dpy_repo) py_version = "[{}.{}.{}]({})".format(*os.sys.version_info[:3], python_url) owner_set = self.bot.settings.owner is not None owner = self.bot.settings.owner if owner_set else None if owner: owner = discord.utils.get(self.bot.get_all_members(), id=owner) if not owner: try: owner = await self.bot.get_user_info(self.bot.settings.owner) except: owner = None if not owner: owner = "Unknown" about = ( "This is an instance of [Red, an open source Discord bot]({}) " "created by [Twentysix]({}) and improved by many.\n\n" "Red is backed by a passionate community who contributes and " "creates content for everyone to enjoy. [Join us today]({}) " "and help us improve!\n\n" "".format(red_repo, author_repo, server_url)) embed = discord.Embed(colour=discord.Colour.red()) embed.add_field(name="Instance owned by", value=str(owner)) embed.add_field(name="Python", value=py_version) embed.add_field(name="discord.py", value=dpy_version) embed.add_field(name="About Red", value=about, inline=False) embed.set_footer(text="Bringing joy since 02 Jan 2016 (over " "{} days ago!)".format(days_since)) try: await self.bot.say(embed=embed) except discord.HTTPException: await self.bot.say("I need the `Embed links` permission " "to send this")
def info(self, ctx): """Show bot's info""" embed = discord.Embed(title="Bot's info", type="rich embed") embed.set_thumbnail(url=discord.utils.find(lambda x: x.id == self.bot.user.id, \ ctx.message.server.members).avatar_url) delta = datetime.now() - self.bot.created_at embed.set_footer(text="Created at " + self.bot.created_at.strftime("%d/%m/%Y %H:%M:%S") + " (" + \ utils.convert_seconds_to_str(delta.total_seconds()) + " ago)") python_version = str(subprocess.check_output("python --version", shell=True))[2:-5] python_version += " " + platform.architecture()[0][:-3] + " bits" commit = str(subprocess.check_output("git rev-parse HEAD", shell=True))[2:-3] os_infos = "Running on " + platform.platform() if platform.machine().endswith("64"): os_infos += " 64 bits" else: os_infos += " 32 bits" embed.add_field(name="Python's version", value=python_version) embed.add_field(name="Commit", value=commit) embed.add_field(name="Bot's version", value=self.bot.version) embed.add_field(name="Discord's version", value=discord.__version__) embed.add_field(name="Environment", value=os_infos) embed.add_field(name="Total commands typed", value=str(self.bot.total_commands + 1)) delta = (datetime.now() - self.bot.launched_at) + self.bot.total_runtime msg = utils.convert_seconds_to_str(delta.total_seconds()) if msg != "": embed.add_field(name="Total run time", value=msg) delta = datetime.now() - self.bot.launched_at msg = utils.convert_seconds_to_str(delta.total_seconds()) if msg != "": embed.add_field(name="Run time", value=msg) embed.add_field(name="Servers", value=str(len(self.bot.servers))) embed.add_field(name="Text channels", value=str(len([x for x in self.bot.get_all_channels() if x.type == discord.ChannelType.text]))) embed.add_field(name="Voice channels", value=str(len([x for x in self.bot.get_all_channels() if x.type == discord.ChannelType.voice]))) known_members = [] for server in self.bot.servers: for member in server.members: if member.id not in known_members: known_members.append(member.id) embed.add_field(name="Members", value=str(len(known_members))) await self.bot.send_message(destination=ctx.message.channel, embed=embed)
def info(self): """Shows info about Red""" author_repo = "https://github.com/Twentysix26" red_repo = author_repo + "/Red-DiscordBot" server_url = "https://discord.gg/red" dpy_repo = "https://github.com/Rapptz/discord.py" python_url = "https://www.python.org/" since = datetime.datetime(2016, 1, 2, 0, 0) days_since = (datetime.datetime.utcnow() - since).days dpy_version = "[{}]({})".format(discord.__version__, dpy_repo) py_version = "[{}.{}.{}]({})".format(*os.sys.version_info[:3], python_url) owner_set = self.bot.settings.owner is not None owner = self.bot.settings.owner if owner_set else None if owner: owner = discord.utils.get(self.bot.get_all_members(), id=owner) if not owner: try: owner = await self.bot.get_user_info(self.bot.settings.owner) except: owner = None if not owner: owner = "Unknown" about = ( "This is an instance of [Red, an open source Discord bot]({}) " "created by [Twentysix]({}) and improved by many.\n\n" "Red is backed by a passionate community who contributes and " "creates content for everyone to enjoy. [Join us today]({}) " "and help us improve!\n\n" "".format(red_repo, author_repo, server_url)) embed = discord.Embed(colour=discord.Colour.red()) embed.add_field(name="Instance owned by", value=str(owner)) embed.add_field(name="Python", value=py_version) embed.add_field(name="discord.py", value=dpy_version) embed.add_field(name="About Red", value=about, inline=False) embed.set_footer(text="Bringing joy since 02 Jan 2016 (over " "{} days ago!)".format(days_since)) try: await self.bot.say(embed=embed) except discord.HTTPException: await self.bot.say("I need the `Embed links` permission " "to send this")