当前位置: 首页>>代码示例>>Python>>正文


Python discord.Game方法代码示例

本文整理汇总了Python中discord.Game方法的典型用法代码示例。如果您正苦于以下问题:Python discord.Game方法的具体用法?Python discord.Game怎么用?Python discord.Game使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord的用法示例。


在下文中一共展示了discord.Game方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sync_cog_on_member_update_other

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def test_sync_cog_on_member_update_other(self):
        """Members should not be patched if other attributes have changed."""
        self.assertTrue(self.cog.on_member_update.__cog_listener__)

        subtests = (
            ("activities", discord.Game("Pong"), discord.Game("Frogger")),
            ("nick", "old nick", "new nick"),
            ("status", discord.Status.online, discord.Status.offline),
        )

        for attribute, old_value, new_value in subtests:
            with self.subTest(attribute=attribute):
                self.cog.patch_user.reset_mock()

                before_member = helpers.MockMember(**{attribute: old_value}, guild=self.guild)
                after_member = helpers.MockMember(**{attribute: new_value}, guild=self.guild)

                await self.cog.on_member_update(before_member, after_member)

                self.cog.patch_user.assert_not_called() 
开发者ID:python-discord,项目名称:bot,代码行数:22,代码来源:test_cog.py

示例2: event_gen

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def event_gen(bot, force=False):
    bot.logger.info("One hour passed, we have to remove the previous event, and find a new one (maybe)")
    bot.current_event = next((item for item in bot.event_list if item['id'] == 0), None)  # Reset the event

    if force or random.randint(0, 100) <= 10:
        bot.logger.debug("[EVENT] A new event will be selected")
        event_id = random.randrange(1, len(bot.event_list))
        bot.logger.info(f"[EVENT] Selected event : {event_id}")
        bot.current_event = next((item for item in bot.event_list if item['id'] == event_id), None)  # Reset the event
        bot.logger.info(f"[EVENT] Selected event : {bot.current_event['name']}")

    else:
        # await bot.log(level=9, title="No new event rolled out", message=f"No event active until the next hour", where=None)

        bot.logger.info("[EVENT] No new event, see you next time!")

    bot.logger.debug("[EVENT] Updating playing status")
    game = discord.Game(name=f"{bot.current_event['name']}")
    await bot.log(level=10, title="New event rolled out", message=f"{bot.current_event['name']} is now the active event until the next hour", where=None)

    await bot.change_presence(status=discord.Status.online, activity=game)
    bot.logger.debug("[EVENT] Done :)") 
开发者ID:DuckHunt-discord,项目名称:DHV3,代码行数:24,代码来源:spawning.py

示例3: switch_status

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def switch_status(self, message):
        if not message.channel.is_private:
            current_game = str(message.server.me.game)
            current_status = message.server.me.status

            if self.last_change == None: #first run
                self.last_change = int(time.perf_counter())
                if len(self.statuses) > 0 and (current_game in self.statuses or current_game == "None"):
                    new_game = self.random_status(message)
                    await self.bot.change_presence(game=discord.Game(name=new_game), status=current_status)

            if message.author.id != self.bot.user.id:
                if abs(self.last_change - int(time.perf_counter())) >= self.settings["DELAY"]:
                    self.last_change = int(time.perf_counter())
                    new_game = self.random_status(message)
                    if new_game != None:
                        if current_game != new_game:
                            if current_game in self.statuses or current_game == "None": #Prevents rndstatus from overwriting song's titles or
                                await self.bot.change_presence(game=discord.Game(name=new_game), status=current_status) #custom statuses set with !set status 
开发者ID:Twentysix26,项目名称:26-Cogs,代码行数:21,代码来源:rndstatus.py

示例4: _presence

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def _presence(self, ctx, type=None, *, game=None):
        '''Change the bot's presence'''
        if type is None:
            await ctx.send(f'Usage: `{ctx.prefix}presence [game/stream/watch/listen] [message]`')
        else:
            if type.lower() == 'stream':
                await self.bot.change_presence(game=discord.Game(name=game, type=1, url='https://www.twitch.tv/a'), status='online')
                await ctx.send(f'Set presence to. `Streaming {game}`')
            elif type.lower() == 'game':
                await self.bot.change_presence(game=discord.Game(name=game))
                await ctx.send(f'Set presence to `Playing {game}`')
            elif type.lower() == 'watch':
                await self.bot.change_presence(game=discord.Game(name=game, type=3), afk=True)
                await ctx.send(f'Set presence to `Watching {game}`')
            elif type.lower() == 'listen':
                await self.bot.change_presence(game=discord.Game(name=game, type=2), afk=True)
                await ctx.send(f'Set presence to `Listening to {game}`')
            elif type.lower() == 'clear':
                await self.bot.change_presence(game=None)
                await ctx.send('Cleared Presence')
            else:
                await ctx.send('Usage: `.presence [game/stream/watch/listen] [message]`') 
开发者ID:cree-py,项目名称:RemixBot,代码行数:24,代码来源:utility.py

示例5: status

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def status(bot):
    gamename = ''
    while not bot.is_closed():
        if bot.is_ready():
            if bot.gamename:
                if bot.gamename != gamename:
                    log.info('Game changed to playing {}'.format(bot.gamename))
                    gamename = bot.gamename
                game = discord.Game(name=bot.gamename)
            else:
                if bot.gamename != gamename:
                    log.info('Removed Game Status')
                    gamename = bot.gamename
                game = None
            await bot.change_presence(game=game, status=discord.Status.invisible, afk=True)
        await asyncio.sleep(20)

# Load Extensions / Logger / Runbot 
开发者ID:lehnification,项目名称:Discord-SelfBot,代码行数:20,代码来源:selfbot.py

示例6: countdown_status

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def countdown_status(bot: commands.Bot) -> None:
    """Set the playing status of the bot to the minutes & hours left until the next day's challenge."""
    while is_in_advent():
        _, time_left = time_left_to_aoc_midnight()

        aligned_seconds = int(math.ceil(time_left.seconds / COUNTDOWN_STEP)) * COUNTDOWN_STEP
        hours, minutes = aligned_seconds // 3600, aligned_seconds // 60 % 60

        if aligned_seconds == 0:
            playing = f"right now!"
        elif aligned_seconds == COUNTDOWN_STEP:
            playing = f"in less than {minutes} minutes"
        elif hours == 0:
            playing = f"in {minutes} minutes"
        elif hours == 23:
            playing = f"since {60 - minutes} minutes ago"
        else:
            playing = f"in {hours} hours and {minutes} minutes"

        # Status will look like "Playing in 5 hours and 30 minutes"
        await bot.change_presence(activity=discord.Game(playing))

        # Sleep until next aligned time or a full step if already aligned
        delay = time_left.seconds % COUNTDOWN_STEP or COUNTDOWN_STEP
        await asyncio.sleep(delay) 
开发者ID:python-discord,项目名称:seasonalbot,代码行数:27,代码来源:adventofcode.py

示例7: on_ready

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def on_ready(self):

        # list of all the cogs.
        cogs = [cog for cog in os.listdir("FAITHFUL_FLEAS/cogs") if cog.endswith(".py")]

        for cog in cogs:
            try:
                # loading the cogs
                self.load_extension("faithful_fleas.cogs." + os.path.splitext(cog)[0])

            except Exception as e:
                # in case any cog/s did not load.
                logger.error(f"Could not load extension {cog} due to error:\n{e}")

        logger.info(f'Running as {self.user.name} with ID: {self.user.id}')
        await self.change_presence(activity=discord.Game(name='A sunny morning!')) 
开发者ID:python-discord,项目名称:code-jam-5,代码行数:18,代码来源:__main__.py

示例8: __init__

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def __init__(self, shard_ids=None, shard_count=None):
        super().__init__(
            shard_ids=shard_ids,
            shard_count=shard_count,
            max_messages=10000,
            activity=discord.Game(name="Embed your Discord server! Visit https://TitanEmbeds.com/")
        )
        self.setup_logger(shard_ids)
        self.aiosession = aiohttp.ClientSession(loop=self.loop)
        self.http.user_agent += ' TitanEmbeds-Bot'
        self.redisqueue = RedisQueue(self, config["redis-uri"])
        self.command = Commands(self, config)
        self.socketio = SocketIOInterface(self, config["redis-uri"])
        
        self.delete_list = deque(maxlen=100) # List of msg ids to prevent duplicate delete
        
        self.discordBotsOrg = None
        self.botsDiscordPw = None 
开发者ID:TitanEmbeds,项目名称:Titan,代码行数:20,代码来源:bot.py

示例9: set_playing

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def set_playing(self, title: str) -> None:
        await self.change_presence(activity=discord.Game(name=title)) 
开发者ID:r-spacex,项目名称:SpaceXLaunchBot,代码行数:4,代码来源:discordclient.py

示例10: convert

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def convert(self, ctx, argument):
        return discord.Game(name=argument) 
开发者ID:Rapptz,项目名称:discord.py,代码行数:4,代码来源:converter.py

示例11: _changepresence

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def _changepresence(self, status=None, msg=None):
        statuslevel = {'online': discord.Status.online, 'idle': discord.Status.idle, 'dnd': discord.Status.dnd}
        status = statuslevel.get(status)
        await self.bot.change_presence(status=status, activity=discord.Game(msg or "D&D 5e | !help"))
        return "Changed presence." 
开发者ID:avrae,项目名称:avrae,代码行数:7,代码来源:adminUtils.py

示例12: __init__

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def __init__(self, config):
        prefixes = ["+", "poll:", "Poll:", "POLL:"]
        super().__init__(
            command_prefix = prefixes,
            status = discord.Status.online,
            activity = discord.Game(name = "+help"))
        self.config = config

        self.remove_command("help")
        
        for extension in extensions:
            self.load_extension(extension) 
开发者ID:stayingqold,项目名称:Poll-Bot,代码行数:14,代码来源:bot.py

示例13: on_ready

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def on_ready(self):
        log.info(f"{self.bot.user.name}#{self.bot.user.discriminator} is online!")
        log.info("--------")
        embed = discord.Embed(
            title=f"[Cluster {self.bot.cluster}] Bot Ready", colour=0x00FF00, timestamp=datetime.datetime.utcnow(),
        )
        await self.bot.http.send_message(self.bot.config.event_channel, None, embed=embed.to_dict())
        await self.bot.change_presence(activity=discord.Game(name=self.bot.config.activity)) 
开发者ID:CHamburr,项目名称:modmail,代码行数:10,代码来源:events.py

示例14: maintain_presence

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def maintain_presence():
    # Loops through the activities specified in activities.csv
    activity = activities.get()
    await bot.change_presence(activity=discord.Game(name=activity)) 
开发者ID:eibex,项目名称:reaction-light,代码行数:6,代码来源:bot.py

示例15: init

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Game [as 别名]
def init(cls, token=None):
        '''Starts the actual bot'''
        bot = cls()
        if token:
            to_use = token.strip('"')
        else:
            to_use = bot.token.strip('"')
        try:
            bot.run(to_use, activity=discord.Game(os.getenv('STATUS')), reconnect=True)
        except Exception as e:
            raise e 
开发者ID:kenng69,项目名称:modmailbotkenng,代码行数:13,代码来源:bot.py


注:本文中的discord.Game方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。