【发布时间】:2021-01-02 23:44:00
【问题描述】:
所以这样做是,如果我在数据库中添加一个单词,它应该在每次输入时为相应单词的计数 +1
我可以将单词添加到数据库中,但计数系统不起作用
@commands.command()
async def wordadd(self, ctx, *args: str):
message = " ".join(args).lower()
word = db.column("SELECT word FROM words")
if message not in word:
db.execute("INSERT OR IGNORE INTO words (word) VALUES (?)",message)
db.commit()
await ctx.send("word has been added")
else:
await ctx.send("word already in there")
async def on_message(self, message):
word = db.column("SELECT word FROM words")
if message in word:
db.execute("UPDATE words SET count = count + 1 WHERE word = ?", message)
db.commit()
如何修复计数系统?
【问题讨论】:
-
message = " ".join(args).lower()可能没有按照您的意愿行事。您可以使用print(" ".join("test").lower())进行测试,这将打印t e s t
标签: python database sqlite discord.py discord.py-rewrite