【问题标题】:What does '*' do as a parameter in discord.py? [duplicate]'*' 作为 discord.py 中的参数有什么作用? [复制]
【发布时间】:2021-10-23 08:24:09
【问题描述】:

我想知道星号作为ban_user函数的参数有什么作用?。我们在哪些情况下使用它?它对 *args 有什么优势?

import discord
from discord.ext import commands


intents = discord.Intents(messages=True, guilds=True, reactions=True, members=True,presences=True)


client = commands.Bot(command_prefix="!dc ", intents=intents)


@client.command(aliases=["ban"])
@commands.has_role("admin")

async def ban_user(ctx, member: discord.Member, *, reason=None):
    await member.ban(reason=reason)

client.run(Token)

【问题讨论】:

  • @luk2302 哦,是的,谢谢

标签: python discord.py


【解决方案1】:

它使成员之后的所有内容/提供的参数都被视为原因。基本上只是指定所有以下单词也是原因参数的一部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-22
    • 1970-01-01
    • 2018-12-24
    • 1970-01-01
    • 2015-02-07
    • 2016-12-05
    • 2021-06-24
    • 1970-01-01
    相关资源
    最近更新 更多