简体   繁体   中英

Discord.py: How do I put a status on a discord bot?

What I have so far, where the #s are are where I might want to place them. of course, in your answer please pick a different location.

The top is cut off:

@client.event
async def on_ready():
    print('Bot is open {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return

   #status thing here?
    if message.content.startswith('gf!ami'):
        await message.channel.send('Hello!')
    if message.content.startswith('gf!help'):
        await message.channel.send(h)
    if message.content.startswith('gf!SEhelp'):
        await message.channel.send(sh)
    if message.content.startswith('gf!music'):
        await message.channel.send
        ("https://open.spotify.com/playlist/49ddWzhNmWxyMuYlvu8L5Z?si=jYlh6zK9RryKSeMlvKZ3yA")
    if message.content.startswith('gf!d6'):
        await message.channel.send(d6())
    if message.content.startswith('gf!cl'):
        await message.channel.send(cl)
    #Status thing here?
client.run('bot token')

Check out documentation for presence updating https://discordpy.readthedocs.io/en/v0.16.12/api.html#discord.Client.change_presence

For example, you should make something like that:

await client.change_presence(game=discord.Game(type=1, url="https://www.twitch.tv/tomori_bot", name="Follow me on twitch ^_^"))

You can see full example there: https://github.com/TomoriBot/Tomori/blob/master/tomori.py at statuses() function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM