Python discord 模块,Status() 实例源码

我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用discord.Status()

项目:dogbot    作者:slice    | 项目源码 | 文件源码
def mods(self, ctx):
        """
        Shows mods in this server.

        A mod is defined as a human in this server with the "Kick Members" permission, or is a Dogbot Moderator.
        """
        is_mod = lambda m: (m.guild_permissions.kick_members or checks.member_is_moderator(m)) and not m.bot
        mods = [m for m in ctx.guild.members if is_mod(m)]

        embed = discord.Embed(title='Moderators in ' + ctx.guild.name, color=discord.Color.blurple(),
                              description=f'There are {len(mods)} mod(s) total in {ctx.guild.name}.')

        for status in discord.Status:
            those_mods = [m for m in mods if m.status is status]
            if not those_mods:
                continue
            embed.add_field(name=str(status).title(), value='\n'.join(str(m) for m in those_mods))

        await ctx.send(embed=embed)
项目:Turbo    作者:jaydenkieran    | 项目源码 | 文件源码
def c_presence(self, author, option=None):
        """
        Changes presence status on Discord

        {prefix}presence <online/idle/dnd/invisible>

        Invisible makes you appear offline.
        Leave blank to reset presence to online.
        """
        afk = False

        if option is None:
            option = 'online'
        else:
            option = option.lower()

        if any(s == option for s in [e.value for e in discord.Status]):
            if option == 'idle':
                afk = True
            await self.bot.change_presence(game=author.game, status=option, afk=afk)
            return Response(":white_check_mark: Set presence to {}!".format(option))
        else:
            raise InvalidUsage()
项目:SIRA-Bot    作者:Hansformer    | 项目源码 | 文件源码
def idle(client, message, parameter):
    await client.change_presence(game=discord.Game(name='with live wires'),
                                 status=discord.Status('idle'),
                                 afk=True)
    await client.send_message(message.channel, '...')


# vision status
项目:SIRA-Bot    作者:Hansformer    | 项目源码 | 文件源码
def vision(client, message, parameter):
    await client.change_presence(game=discord.Game(name='V I S I O N'),
                                 status=discord.Status('online'),
                                 afk=False)
    await client.send_message(message.channel, 'I have been V I S I O N\'d.')


# trigger definitions
项目:Excalibot    作者:endreman0    | 项目源码 | 文件源码
def __init__(self, cfg):
        super().__init__(
            config.get_prefix,
            description='Welcome. Welcome to my guild young ones. Please forgive the belated salutations. I am the holy program Excalibot!',
            command_not_found='BAKA! That command does not exist!',
            status=discord.Status[cfg['status']]
        )
        self.config = cfg
        self.ready = False
        self.session = db.Session()
        self.check(self.permission_check)
项目:Excalibot    作者:endreman0    | 项目源码 | 文件源码
def on_ready(self):
        log.info('Logged in as %s (%s)', self.user, self.user.id)
        game_config = self.config['game']
        if game_config is not None:
            game_config = dict(game_config) # Copy, to write in formatted game name
            game_config['name'] = game_config['name'].format(client=self, guild_count=len(self.guilds))
            await self.change_presence(status=discord.Status[self.config['status']], game=discord.Game(**game_config)) # Must set status again, as leaving it empty will revert to Online
        self.ready = True
项目:endrebot0    作者:endreman0    | 项目源码 | 文件源码
def game(ctx, game, status=None):
    status = discord.Status[status] if status else discord.Status.online
    await ctx.bot.change_presence(status=status, game=discord.Game(name=game))
    await ctx.message.delete()
项目:endrebot0    作者:endreman0    | 项目源码 | 文件源码
def afk(ctx, *args, status=None, **kwargs):
    await afk_send(ctx, 'afk_message', *args, **kwargs)
    if status == 'offline':
        await ctx.bot.change_presence(status=discord.Status.invisible)
    elif status is not None:
        await ctx.bot.change_presence(status=discord.Status[status], game=discord.Game(name='AFK: ' + ', '.join(args)))
项目:Uso-Bot    作者:Renondedju    | 项目源码 | 文件源码
def status(ctx):
    rank, channel, message = await init_command(ctx.message)
    if rank in ['ADMIN', 'MASTER']:
        parameters = message.content.replace(commandPrefix + 'status ', "")
        playmessage = parameters.split(" | ")[0]
        status = parameters.split(" | ")[1]
        await asyncio.sleep(1)
        await client.change_presence(game=discord.Game(name=playmessage), status=discord.Status(status))
        await client.send_message(channel, "Play message set to:``" + playmessage + "``, status set to:``" + status + "``")
    else:
        await missing_permissions_message(channel)
项目:Uso-Bot    作者:Renondedju    | 项目源码 | 文件源码
def on_ready():
    global mainChannel, logsChannel, visible, databasePath, botOwner, Refresh
    mainChannel = client.get_server(constants.Settings.mainServerID).get_channel(constants.Settings.mainChannelId)
    logsChannel = client.get_server(constants.Settings.mainServerID).get_channel(constants.Settings.logsChannelId)
    print('Logged in !')

    botOwner = await client.get_user_info(str(constants.Settings.ownerDiscordId))
    hello = False

    if (datetime.now().strftime('%H') == "02" and Refresh) or ((set(sys.argv) & set(["refresh"])) and Refresh):
        await change_presence(status=discord.Status('dnd'), game=discord.Game(name='Booting ...'))
        message = await client.send_message(mainChannel, "<:empty:317951266355544065> Updating stats ...")
        #try:
        print('Refreshing users stats ...')
        update_stats.update_all_stats(conn, cursor)
        Refresh = False
        print(" - Done")
        print('Creating new backup ...', end="")
        create_backup()
        print(" Done !")
        await client.edit_message(message, "<:check:317951246084341761> Updating stats ... Done !")
        # except:
        #   await client.edit_message(message, "<:xmark:317951256889131008> Updating stats ... Fail !")
        if not set(sys.argv) & set(["dev"]):
            await client.send_message(mainChannel, "<:online:317951041838514179> Uso!<:Bot:317951180737347587> is now online !")
            await change_presence(status=discord.Status('online'), game=discord.Game(name='Osu !'))
            hello = True
    if (set(sys.argv) & set(["online"])) and hello == False:
        await client.send_message(mainChannel, "<:online:317951041838514179> Uso!<:Bot:317951180737347587> is now online !")
    if set(sys.argv) & set(["dev"]):
        await change_presence(status=discord.Status('idle'), game=discord.Game(name='Dev mode'))
    else:
        await change_presence(status=discord.Status('online'), game=discord.Game(name='o!help'))
    print ('Ready !')
项目:dogbot    作者:slice    | 项目源码 | 文件源码
def on_message(self, message: discord.Message):
        # do not handle invisibility in dms
        if isinstance(message.channel, discord.abc.PrivateChannel):
            return

        if await self.bot.config_is_set(message.guild, 'invisible_nag'):
            if message.author.status is discord.Status.offline:
                reply = 'Hey {0.mention}! You\'re invisible. Stop being invisible, please. Thanks.'
                await message.channel.send(reply.format(message.author))
项目:tuxbot-bot    作者:outout14    | 项目源码 | 文件源码
def on_ready():
    print('---------------------')
    print('Logged in as :')
    print('Username: ' + bot.user.name)
    print('ID: ' + str(bot.user.id))
    print('---------------------')
    await bot.change_presence(game=discord.Game(name="Manger des pommes ! .help !"), status=discord.Status("dnd"), afk=False)
    if not hasattr(bot, 'uptime'):
        bot.uptime = datetime.datetime.utcnow()
项目:dango.py    作者:khazhyk    | 项目源码 | 文件源码
def __init__(self, bot, config, http):
        self.declare_metric(
            "opcodes", prometheus_client.Counter, 'Opcodes', ['opcode'])
        self.declare_metric(
            "dispatch_events", prometheus_client.Counter, 'Dispatch Events', ['event'])
        self.declare_metric(
            "command_triggers", prometheus_client.Counter, 'Command Triggers', ['command'])
        self.declare_metric(
            "command_completions", prometheus_client.Counter, 'Command Completions', ['command'])
        self.declare_metric(
            "command_errors", prometheus_client.Counter, 'Command Errors', ['command', 'error'])
        self.declare_metric(
            "command_timing", prometheus_client.Histogram, 'Command Timing', ['command'])
        self.declare_metric(
            "server_count", prometheus_client.Gauge, "Server Count",
            function=lambda: len(self.bot.guilds))
        self.declare_metric(
            "member_count", prometheus_client.Gauge, "Member Count", ['status'])
        for status in discord.Status:
            self.member_count.labels(status=status.name).set_function(
                _count_members_fac(bot, status))

        for opcode in OPCODE_NAMES.values():
            self.opcodes.labels(opcode=opcode)

        for dispatch_name in DISPATCH_NAMES:
            self.dispatch_events.labels(event=dispatch_name)

        self._in_flight_ctx = {}
        self.bot = bot

        http.add_handler("GET", "/metrics", self.handle_metrics)