【发布时间】:2021-03-01 16:39:04
【问题描述】:
你好
我试图让我的不和谐机器人将他从 txt 文件中读出的内容作为 dm 发送给用户。我做了一个命令,它创建一个 txt 文件,该文件应该保护有关用户创建的帐户的一些详细信息。现在我希望用户能够通过在不和谐聊天中发送命令来查看他的帐户详细信息。
进口
import discord
from random import *
from time import *
from discord.ext import tasks
from discord.ext import commands
import asyncio
import os.path
创建文件
@bot.command()
async def join(ctx):
if os.path.isfile("{}'s Account.txt".format(ctx.author)):
em=discord.Embed(title="Fail", description="im sorry, but it seems like you already have an account".format(ctx),color=0x992d22)
await ctx.author.send(embed=em)
else:
em=discord.Embed(title="Welcome", description="You have joined the game.\n send !help to see all the commands.".format(ctx),color=0x2ecc71)
await ctx.author.send(embed=em)
open("{}'s Account.txt".format(ctx.author), "w+")
myFile=open("{}'s Account.txt".format(ctx.author), "a")
myFile.write("Verified! \n Coins=0 \n Attack=0 \n Defense=0 \n")
应向用户发送包含帐户详细信息的 dm
async def credit(ctx):
Account=open("{}'s Account.txt".format(ctx.author))
lines = Account.
em=discord.Embed(title="Balance", description="")
em.add_field(name="Coins", value="")
await ctx.author.send(embed=em)
"{}'s Account.txt".format(ctx.author.close)
我想要达到的目标
命令 collect 应该向用户发送一个嵌入字段,其中包含另外 4 个字段,其中应该包含标题硬币防御和攻击。我希望该命令读取相应属性的整数,然后将它们插入具有相应标题的字段中。
【问题讨论】:
标签: python filter integer command discord.py