如何在赠品中为用户提供多个条目
How to give users multiple entries in a giveaway
我一直在尝试用 discord.py 制作一个机器人来检查服务器上所有用户的状态。我让机器人每隔一小时进行一次循环,并向状态为 'status' 的任何用户添加一个条目。那部分效果很好,但是,我不知道如何为拥有更多条目的用户提供更高的获胜机会。例如,在一个有 3 个人的服务器中,人 1 有 1 个条目,2 有 2 个条目,3 有 2 个条目。我会给第 2 个人和第 3 个人都是第 1 个人获胜机会的 2 倍。没有错误,因为我只是想弄清楚该怎么做。
@client.command()
@commands.has_role("developer")
async def startloop(ctx):
print(data)
while True:
allmembers = ctx.guild.members
for i in allmembers:
for x in i.activities:
if isinstance(x, discord.CustomActivity):
if str(x) == 'status':
print('status detected')
for d in data:
if d['id'] == i.id:
d['entries'] = d['entries'] + 1
await ctx.send('test')
print(data)
pass
time.sleep(3600)
@client.command()
@commands.has_role("developer")
async def gstart(ctx):
#trying to make the giveaway command
列出数字:[1 ... n]。 N 是条目总数。然后在 1 到 n 之间选择一个随机数。持有第 n 个条目的人将赢得抽奖。您将需要跟踪用户在列表中的条目。例如,用户 1 可能有条目:[1, 2, 3]。用户 2:[4, 5, 6, 7],依此类推。随机数将在某些用户的条目列表中。
我一直在尝试用 discord.py 制作一个机器人来检查服务器上所有用户的状态。我让机器人每隔一小时进行一次循环,并向状态为 'status' 的任何用户添加一个条目。那部分效果很好,但是,我不知道如何为拥有更多条目的用户提供更高的获胜机会。例如,在一个有 3 个人的服务器中,人 1 有 1 个条目,2 有 2 个条目,3 有 2 个条目。我会给第 2 个人和第 3 个人都是第 1 个人获胜机会的 2 倍。没有错误,因为我只是想弄清楚该怎么做。
@client.command()
@commands.has_role("developer")
async def startloop(ctx):
print(data)
while True:
allmembers = ctx.guild.members
for i in allmembers:
for x in i.activities:
if isinstance(x, discord.CustomActivity):
if str(x) == 'status':
print('status detected')
for d in data:
if d['id'] == i.id:
d['entries'] = d['entries'] + 1
await ctx.send('test')
print(data)
pass
time.sleep(3600)
@client.command()
@commands.has_role("developer")
async def gstart(ctx):
#trying to make the giveaway command
列出数字:[1 ... n]。 N 是条目总数。然后在 1 到 n 之间选择一个随机数。持有第 n 个条目的人将赢得抽奖。您将需要跟踪用户在列表中的条目。例如,用户 1 可能有条目:[1, 2, 3]。用户 2:[4, 5, 6, 7],依此类推。随机数将在某些用户的条目列表中。