【发布时间】:2020-08-31 13:39:29
【问题描述】:
我用 MongoDB 创建了一个不和谐的机器人,并创建了一个命令来修改我的机器人商店中的一篇文章。 在修改特定文章之前,它必须已经在数据库中找到。是否可以查明在命令中键入的名称是否存在于数据库中?如果不存在,则返回错误消息。
if(!oldName) return message.channel.send('<:croix:704272420873306165> You must indicate the name of your article')
if(!newName) return message.channel.send('<:croix:704272420873306165> You must indicate the new name for your article')
if() return message.channel.send('<:croix:704272420873306165> The name of the item doesn\'t exist.')
await serverDB.set(message.guild.id, { $rename: { [ 'modules.SHOPECO.' + oldName ] : 'modules.SHOPECO.' + newName } })
await serverDB.set(message.guild.id, { $set: { [ 'modules.SHOPECO.' + `${newName}.NAME` ] : newName } })
message.channel.send("Good !")
【问题讨论】:
-
告诉我们你到目前为止做了什么?你卡在哪里了?
-
你在用猫鼬吗?
-
@Syntle 是的,我正在使用猫鼬
-
@SamimHakimi 我给你看了我上面的程序,第三个条件是空的,因为这就是我要问你的问题
-
@Cyra 请看看我的回答。
标签: mongodb mongoose discord.js