python类Game()的实例源码

randgame.py 文件源码 项目:tmerc-cogs 作者: tmercswims 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def _set(self, ctx: commands.Context, *games: str):
        """Replaces the game list with the given list."""

        games_str = ", ".join(sorted(list(games)))

        await self.bot.reply(cf.question(
            "You are about to replace the current game list with this:{}"
            "Are you sure you want to proceed? (yes/no)".format(
                cf.box(games_str))))

        answer = await self.bot.wait_for_message(timeout=15,
                                                 author=ctx.message.author)

        if answer is None or answer.content.lower().strip() != "yes":
            await self.bot.reply("Game list not replaced.")
            return

        self.settings["del"] += self.settings["games"]

        self.settings["games"] = list(games)
        dataIO.save_json(self.settings_path, self.settings)

        await self.bot.reply(cf.info("Game list replaced."))
rndstatus.py 文件源码 项目:26-Cogs 作者: Twentysix26 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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
bot.py 文件源码 项目:YeeBot 作者: jaspric 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def on_ready():
    print("Client logged in.")
    print(yeebot.user.name)
    print(yeebot.user.id)
    print('-----')
    await yeebot.change_presence(game=discord.Game(name="Memes"))
bot.py 文件源码 项目:pineapple 作者: peter765 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def on_ready():
    """
    Event handler, fires when the bot has connected and is logged in
    """
    logging.info('Logged in as ' + client.user.name + " (" + client.user.id + ")")

    # Change nickname to nickname in configuration
    for instance in client.servers:
        await client.change_nickname(instance.me, pm.botPreferences.nickName)

        # Load rank bindings
        pm.botPreferences.bind_roles(instance.id)
    await client.change_presence(game=discord.Game(name='Use ' + pm.botPreferences.commandPrefix + 'help for help'))
    await pm.handle_loop()
meta.py 文件源码 项目:Harmonbot 作者: Harmon758 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def setgame(self, ctx, *, name : str):
        '''Set my playing/game status message'''
        updated_game = ctx.message.server.me.game
        if not updated_game:
            updated_game = discord.Game(name = name)
        else:
            updated_game.name = name
        await self.bot.change_status(game = updated_game)
        await self.bot.embed_reply("Game updated")
meta.py 文件源码 项目:Harmonbot 作者: Harmon758 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def cleargame(self, ctx):
        '''Clear my playing/game status message'''
        updated_game = ctx.message.server.me.game
        if updated_game and updated_game.name:
            updated_game.name = None
            await self.bot.change_status(game = updated_game)
            await self.bot.embed_reply("Game status cleared")
        else:
            await self.bot.embed_reply(":no_entry: There is no game status to clear")
clients.py 文件源码 项目:Harmonbot 作者: Harmon758 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def set_streaming_status(client):
    me = discord.utils.get(client.servers).me
    if not me:
        return
    elif not me.game:
        updated_game = discord.Game(url = stream_url, type = 1)
    else:
        updated_game = me.game
        updated_game.url = stream_url
        updated_game.type = 1
    await client.change_presence(game = updated_game)
Settings.py 文件源码 项目:CorpBot.py 作者: corpnewt 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def ownerlock(self, ctx):
        """Locks/unlocks the bot to only respond to the owner."""
        author  = ctx.message.author
        server  = ctx.message.server
        channel = ctx.message.channel

        try:
            owner = self.serverDict['Owner']
        except KeyError:
            owner = None

        if owner == None:
            # No previous owner, let's set them
            msg = 'I cannot be locked until I have an owner.'
            await self.bot.send_message(channel, msg)
            return
        else:
            if not author.id == owner:
                msg = 'You are not the *true* owner of me.  Only the rightful owner can change this setting.'
                await self.bot.send_message(channel, msg)
                return
            # We have an owner - and the owner is talking to us
            # Let's try and get the OwnerLock setting and toggle it
            try:
                ownerLock = self.serverDict['OwnerLock']
            except KeyError:
                ownerLock = "No"
            # OwnerLock defaults to "No"
            if ownerLock.lower() == "no":
                self.serverDict['OwnerLock'] = "Yes"
                msg = 'Owner lock **Enabled**.'
                await self.bot.change_presence(game=discord.Game(name="OwnerLocked"))
            else:
                self.serverDict['OwnerLock'] = "No"
                msg = 'Owner lock **Disabled**.'
                await self.bot.change_presence(game=None)
            await self.bot.send_message(channel, msg)
            #self.flushSettings()
Bot.py 文件源码 项目:CorpBot.py 作者: corpnewt 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def onready(self):
        # Get ready - play game!
        game = None
        try:
            game = self.settings.serverDict['Game']
        except KeyError:
            pass
        if game:
            await self.bot.change_presence(game=discord.Game(name=game))
        else:
            await self.bot.change_presence(game=None)
Main.py 文件源码 项目:ubi 作者: ubidiscordbot 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def on_ready():
    global mds
    mds = moduleHandler.MdHandle(client)
    await client.change_presence(game=discord.Game(name=';help to start'))
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
voice.py 文件源码 项目:BuffBot 作者: Cmoen11 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def play_music(self, link):
        # Get the voice channel the commanding user is in
        trigger_channel = self.music_server
        # Return with a message if the user is not in a voice channel
        if trigger_channel is None:
            await self.bot.say("You're not in a voice channel right now")
            return
        if self.voice:
            if self.voice.channel.id != trigger_channel.id:
                # If the bot is in voice, but not in the same channel, move to the commanding user
                await self.voice.move_to(trigger_channel)
        else:
            # If the bot is not in a voice channel, join the commanding user
            self.voice = await self.bot.join_voice_channel(trigger_channel)
        # Stop the player if it is running, to make room for the next one
        if self.player:
            self.player.stop()
        # Create a StreamPlayer with the requested link
        self.player = await self.voice.create_ytdl_player(link)

        await global_methods.music_playing(self.player, self.bot, self.music_server.server)   # print out music information

        self.player.volume = self.volume                                                # set the volume
        self.player.start()                                                             # starts the song
        await self.bot.change_presence(game=discord.Game(name=self.player.title))       # change bot presence

        self.seconds_to_next = self.player.duration
        await self.queue_is_alive()
voice.py 文件源码 项目:BuffBot 作者: Cmoen11 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def queue_is_alive(self):
        while self.seconds_to_next > 0:
            self.seconds_to_next -= 1
            await asyncio.sleep(1)

        self.people_voted.clear()
        # if there is an item at the front of the queue, play it and get the next item
        if self.playlist.current:
            await self.play_music(self.playlist.pop())
            await asyncio.sleep(5)

        elif self.playlist.current is None:
            await self.play_music(link=self.database.get_random_music())
            #await self.bot.change_presence(game=discord.Game(name='Queue is empty'))
_Main.py 文件源码 项目:Sparcli 作者: 4Kaylum 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def on_ready():
    print('-----')
    print('User :: {}'.format(sparcli.user))
    print('ID :: {}'.format(sparcli.user.id))
    print('-----')

    # Load the extentions
    for extension in initialExtentions:
        # This is necessary because I'm bad at code lol
        try:
            sparcli.load_extension(extension)

        # Print out any errors
        except Exception as e:
            exc = '{}: {}'.format(type(e).__name__, e)
            print('Failed to load extension {}\n{}'.format(extension, exc))

    # Load up any changes that would have been made to the configs
    for server in sparcli.servers:
        z = getServerJson(server.id)
        z = fixJson(z)
        saveServerJson(server.id, z)

    # Reccursively fix any globals too
    z = getServerJson('Globals')
    z = fixJson(z)
    saveServerJson('Globals', z)

    # Changed the bot's game
    game = '@Spar.cli help'
    await sparcli.change_presence(game=discord.Game(name=game))
mod.py 文件源码 项目:Kurisu-Reswitched 作者: 916253 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def playing(self, ctx, *gamename):
        """Sets playing message. Staff only."""
        try:
            await self.bot.change_presence(game=discord.Game(name='{}'.format(" ".join(gamename))))
        except discord.errors.Forbidden:
            await self.bot.say("?? I don't have permission to do this.")
lagbot.py 文件源码 项目:lagbot 作者: mikevb1 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def set_game(self, name):
        if name is not None:
            game = discord.Game(name=f'{name} {self.resumes or ""}')
        await self.change_presence(game=game, status=discord.Status.dnd if self._debug else discord.Status.online)
        self.game = name
bot.py 文件源码 项目:Socrates 作者: Curlybear 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def on_ready():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)
    print('------')
    logger.info('Bot started as ' + bot.user.name)
    for server in bot.servers:
        logger.info('   ' + server.name)
    await bot.change_presence(game=discord.Game(name='eRepublik'))
plugin.py 文件源码 项目:globibot 作者: best-coloc-ever 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def status(self, message):
        status = message.clean_content[len('!status'):].strip()
        await self.bot.change_status(Game(name=status))
TabbesBot.py 文件源码 项目:TabbesBot 作者: RealSnoozemonster 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def on_ready(self):
    self.out.Success("Client ready! Logged in as " + self.user.id)
    yield from self.change_presence(game=discord.Game(name='=help for help'))
bot.py 文件源码 项目:PomodoroBot 作者: VicenteRD 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def update_status(self):
        """ Updates the status of the bot user to display the amount of
            timers running, if any, or show the bot as idle if none are.
        """

        if self.timers_running == 0:
            await self.change_presence(game=None, status=Status.idle)

        else:
            game = discord.Game()
            channels = lib.pluralize(self.timers_running, "channel", append="s")
            game.name = ("on " + channels)

            await self.change_presence(game=game, status=Status.online)
admin.py 文件源码 项目:AceBot 作者: Run1e 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def game(self, ctx, *, presence = None):
        """Change bot presence."""
        if presence == None:
            presence = self.bot.info['status']
        await self.bot.change_presence(game=discord.Game(name=str(presence)))

    # if this doesn't work, I changed how id is casted to int


问题


面经


文章

微信
公众号

扫码关注公众号