【发布时间】:2022-01-13 18:24:58
【问题描述】:
因此,例如,在常规静音命令中,机器人正在获取更新,静音命令留在最后一点,永远不会取消用户静音!所以我创建了一个数据库,并将当前静音的 user_id 和日期时间存储为最终取消静音时间,还存储了公会的 id。
例如,当我开始更新时,静音会保存到数据库中,以便稍后从 on_ready 事件中提取。然后我拉取值,然后执行discord.utils.sleep_until(dateime #aka the final unmute time),完成后取消用户静音。
问题来了:我怎样才能得到存储在数据库中的公会ID,并从数据库中取出公会中的静音角色(因为服务器又名“ctx”不再是东西)?
语言 - Python, 数据库——mysql
+----------------------------------------
|user1 |datetime(of the unmute)|guild_id|
+----------------------------------------
mute - inserts the above info^^^
def on_ready():
print("ready")
selects the values
discord.utils_sleep_until(datetime of unmute)
take away role in guild
如果我目前的方法不是最好的,我当然愿意接受更好的建议。
【问题讨论】:
-
请包含一些代码,以便我们可以看到您到目前为止所做的事情!
-
这更像是一个概念性问题,我们不想在不知道这种方式是否可行的情况下进行编码,但类似于上面的内容^
-
How can I get the server's/guild's id(which is stored in the database) and take away the muted role in the guild gotten from the database(since the server aka "ctx" is no longer a thing!)- 不是概念问题。它是关于如何编写代码/如何工作的。如果您在将角色授予成员时存储了guild,您确实可以从数据库中获取它。因此,我们需要知道您的代码的外观/您如何存储所有内容。
标签: mysql discord.py