改变不和.py机器人状态

2024-03-28 17:36:03 发布

您现在位置:Python中文网/ 问答频道 /正文

对我来说可能很难,但我相信stackoverflow的力量

我需要在我的机器人上输入一个数字作为机器人状态。在

这里:http://gamers-control-2.000webhostapp.com/count.txt

还有图片:Picture

#time to show status = text that founded in blank website = "41"

#http://gamers-control-2.000webhostapp.com/count.txt

#some how, you say i can type the number, i say the number in web it change everytime, so i need to get that number to show it as bot status.

import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
import random
from discord import Game


Client = discord.client
client = commands.Bot(command_prefix = '!')
Clientdiscord = discord.Client()




@client.event
async def on_ready():

 await client.change_presence(game=discord.Game(name=http://gamers-control-2.000webhostapp.com/count.txt, type=3))

 print('test ready')

client.run("....")

我是新来的不和.py在


Tags: tofromimporttxtcomclienthttpnumber
1条回答
网友
1楼 · 发布于 2024-03-28 17:36:03

我这样使用await bot.change_presence()

注意:

我漏掉了部分代码

@bot.event
async def on_ready():
    replit.clear()
    print(f'Logged in as {bot.user.name} - {bot.user.id}')
    bot.remove_command('help')
    await bot.change_presence(status=discord.Status.online, activity=discord.Game("mod help"))
网友
2楼 · 发布于 2024-03-28 17:36:03

您需要首先在开始时导入请求

import requests

然后在准备活动之前

^{pr2}$

然后你把它设为

await client.change_presence(game=discord.Game(name=count.text, type=3))

相关问题 更多 >