[英]How to set bot's custom status with Discord.py
I've just gotten started with Discord.py, and I would like to set a custom status for it, ie "Watching for e/info" but am not sure how to do that.我刚刚开始使用 Discord.py,我想为它设置一个自定义状态,即“正在查看电子/信息”,但不知道该怎么做。 Only thing found on SO was for Discord.js.在 SO 上找到的唯一东西是 Discord.js。
My code:我的代码:
import os
import random
from dotenv import load_dotenv
from discord.ext import commands
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
bot = commands.Bot(command_prefix='e/')
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Activity
(type=discord.ActivityType.watching name="for e/info"))
@bot.command(name='info')
async def info(ctx):
await ctx.send('Prefix: /e) Commands: \n -info => Shows commands')
bot.run(TOKEN)
(I followed a tutorial for this minus the Status thing, I think I'm missing an import
statement, I'm just not sure what to import
.) (我遵循了这个减去状态的教程,我想我缺少一个import
语句,我只是不确定要import
什么。)
Using the .change_presence()
method.使用.change_presence()
方法。 Assuming you're using discord.Client()
假设您使用的是discord.Client()
await client.change_presence(activity=discord.Game(name='Watching for e/info'))
Also there's different kinds of statuses, Playing, Watching, Listening, and Streaming.还有不同类型的状态,播放、观看、收听和流媒体。 So if you wanted it to use Watching, do this instead.因此,如果您希望它使用 Watching,请改为执行此操作。
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="for e/info"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.