(key: any, value: any)
| 7 | * */ |
| 8 | export class BotOnlyMessageCollection<K, V> extends LimitedCollection<K, V> { |
| 9 | public set(key: any, value: any) { |
| 10 | const msg = value as Message; |
| 11 | // skip authors that are not the bot |
| 12 | if (msg.author.id !== CLIENT.user.id) return this; |
| 13 | // skip if this collection size is 0 |
| 14 | if (this.maxSize === 0) return this; |
| 15 | // cache item |
| 16 | super.set(key, value); |
| 17 | // evict oldest message if collection is full |
| 18 | if (this.size >= this.maxSize) { |
| 19 | this.delete(this.keys().next().value); |
| 20 | } |
| 21 | return this; |
| 22 | } |
| 23 | } |
no outgoing calls
no test coverage detected