小编Pal*_*h35的帖子

使用 discord.py 获取频道的名称

如何获取频道的名称,以便该机器人可以在其放置的任何服务器上运行,而无需更改代码?(在我放置“我在这里放什么”的代码中,我希望名称在变量中)谢谢

from discord.ext.commands import Bot
import time, asyncio

TOKEN = 'Its a secret'
BOT_PREFIX = ["!"]
client = Bot(command_prefix=BOT_PREFIX)




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




@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')
    await start()
    while True:
        currentTime = time.strftime("%M%S", time.gmtime(time.time()))
        if currentTime == "30:00":
            await start()
        await asyncio.sleep(1)


async def start():
    mainChannel = #What do i put here?
    print(mainChannel.name)
    await client.send_message(mainChannel, "Starting countdown", tts = True)



client.run(TOKEN)
Run Code Online (Sandbox Code Playgroud)

python discord discord.py

6
推荐指数
2
解决办法
3万
查看次数

"newly" installed visual studio returns 408 errors on blank program of type 'cannot open source file "errno.h" '

Having installed VS 2019 on my PC, and opening up a new project, i get 408 errors that all say it cannot open various source .h files, such as errno.h, float.h, corecrt.h, etc. or 'the global scope has no "acosf" 'I had just installed visual studio and have no clue how it works, and have not done anything other than install it and open up a new project. Possibly useful information:

  • It was not installed in the default location, but …

c++ visual-studio visual-c++

2
推荐指数
1
解决办法
1382
查看次数

标签 统计

c++ ×1

discord ×1

discord.py ×1

python ×1

visual-c++ ×1

visual-studio ×1