1 回答
TA贡献1797条经验 获得超6个赞
正如变量提到的:
您可以使用Maps并将键设置为公会 ID,将值设置为要列入黑名单的单词数组。
这是一个关于如何做到这一点的简单示例:
const blacklist = new Map();
// the key (message.guild.id), is how you'll be able to reference this element in the future
blacklist.set(message.guild.id, { blacklisted: ['@#$%'] });
// returns array: ['@#$%']
blacklist.get(message.guild.id).blacklisted
代码片段:
const blacklist = new Map();
// the key (message.guild.id), is how you'll be able to reference this element in the future
blacklist.set('example', { blacklisted: ['@#$%'] });
console.log(blacklist.get('example').blacklisted);
blacklist.get('example').blacklisted.push('*&^%');
console.log(blacklist.get('example').blacklisted);
console.log(blacklist.has('notExample'));
添加回答
举报