【发布时间】:2020-07-20 14:56:01
【问题描述】:
这正是我试图开始工作的应用程序:我试图允许用户为“状态”参数输入多个单词。
即!setstatus 玩英雄联盟
显示“Playing League”而不是整个字符串。我明白为什么,但是如何格式化参数以接受多个单词作为参数?我什至可以这样做吗?
@bot.command()
@commands.has_role('Bot Boss')
async def setstatus(ctx, action, status, url = None):
accepted_actions = ['playing', 'streaming', 'listening', 'watching']
if action.lower() not in accepted_actions:
await ctx.send("First parameter must be 'playing', 'streaming', 'listening', or 'watching'.")
if action.lower() == 'playing':
await bot.change_presence(activity = discord.Game(name = status))
if action.lower() == 'streaming':
await bot.change_presence(activity = discord.Streaming(name = status, url = url))
if action.lower() == 'listening':
await bot.change_presence(activity = discord.Activity(type=discord.ActivityType.listening, name=status))
if action.lower() == 'watching':
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=status))
【问题讨论】:
标签: python python-3.x bots discord.py