我有以下代码:
import discord
from discord.ext import commands
import time
import random
client = commands.Bot(command_prefix='n!')
token = 'token'
peopleid = [id1, id2]
@client.event
async def on_ready():
print('Bot online!')
await client.change_presence(activity=discord.Game(name="presence"))
@client.command()
async def botsend(ctx, args, ):
messagep = f'message'
if args == 'on':
#random.choice(peopleid)
print('ON')
await ctx.send('dm messaging has been turned on')
while True:
await ctx.send(f'{messagep}')
print('messaged')
time.sleep(2)
if args == 'off':
await ctx.send('dm messaging has been turned off')
print('OFF')
client.run(token)
我想使用 peopleid
从 random.choice
中选择一个随机 ID,然后向相应的用户发送 DM。我该怎么做?