如何在不和谐中区分来自不同成员的输入?

问题描述

我正在尝试记录 discord 服务器上不同成员的读取计数总和。我想出了如何获得读取计数的总和,但是我的代码给了我服务器中每个人的总和。我如何让它计算每个成员的总和?

import discord
from discord.ext import commands

client = commands.Bot(command_prefix = ".")

member_rc = [0]

@client.event
async def on_ready():
    print("Bot is ready.")
  
@client.command("rcc")
async def rc(ctx,*,user_input):
    """
    recieves the member's read count and outputs the sum of that member's read count.
    ex: 
    .rcc Taylor 123
    >>> Taylor just read 123 words. 
    Their total read count is 1123 words.
    
    .rcc Anna 200
    >>> Anna just read 200 words.
    Their total read count is 2200 words.
    """

    member_name,number = user_input.split(" ") #seperate the member's name and read count. 
    member_name = str(member_name)
    
    number = int(number)
    
    member_rc.append(number) #adds the member's read count to their list
    
    await ctx.send(f"{member_name} just read {number} words.\nTheir total read count is {sum(member_rc)} words.")
    

client.run('TOKEN')

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)