javascript - 如何从缓存中删除用户
问题描述
我正在使用discord.js
v12.3.1
我想知道我应该如何从缓存中删除用户。例如:
// this would successfully get the user data
client.users.cache.get('<ID Here>');
// delete user from cache
// this time it returns undefined, as the user is no longer stored in the cache
client.users.cache.get('<Same ID>');
有什么办法可以做到吗?
解决方案
discord.js collection .delete()
使用该方法从缓存中删除用户、公会、频道、表情符号等非常容易。
使用此方法的一个简单示例:
.delete()
true
如果找到并删除了该元素,或者false
该元素不存在,则将返回。它也等同于Map.prototype.delete()
推荐阅读
- c++ - 构建错误 - '.' 之前的预期主表达式 令牌
- qt - 如何在不重新安装 Qt 工具包的情况下从 Qt Enterprise 迁移到 Qt Opensource?
- blockchain - 准备消息的摘要是副本的摘要,还是与主在 PBFT 中发送的预准备的签名相同?
- html - 如何动态合并表格中的单元格
- vba - Document.SaveAs2 Document.WdSaveFormat这两种方法有什么区别
- javascript - 有没有办法从服务人员打开 mailto: 和 tel: 链接?
- android - 未找到用于 react-native 的 Android SDK
- css - 有没有办法调整背景图像的大小以适应移动像素
- apache - How to add icon in httpd.config file
- php - 如何比较两个数组值并返回我想要的值?