fix async iterator
This commit is contained in:
parent
1e53d7d770
commit
5e65673107
3 changed files with 7 additions and 3 deletions
|
@ -63,7 +63,9 @@ export class BaseManager<T, T2> {
|
||||||
async *[Symbol.asyncIterator](): AsyncIterableIterator<T2> {
|
async *[Symbol.asyncIterator](): AsyncIterableIterator<T2> {
|
||||||
const arr = (await this.array()) ?? []
|
const arr = (await this.array()) ?? []
|
||||||
const { readable, writable } = new TransformStream()
|
const { readable, writable } = new TransformStream()
|
||||||
arr.forEach((el) => writable.getWriter().write(el))
|
const writer = writable.getWriter()
|
||||||
|
arr.forEach((el: unknown) => writer.write(el))
|
||||||
|
writer.close()
|
||||||
yield* readable
|
yield* readable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,9 @@ export class BaseChildManager<T, T2> {
|
||||||
async *[Symbol.asyncIterator](): AsyncIterableIterator<T2> {
|
async *[Symbol.asyncIterator](): AsyncIterableIterator<T2> {
|
||||||
const arr = (await this.array()) ?? []
|
const arr = (await this.array()) ?? []
|
||||||
const { readable, writable } = new TransformStream()
|
const { readable, writable } = new TransformStream()
|
||||||
arr.forEach((el: unknown) => writable.getWriter().write(el))
|
const writer = writable.getWriter()
|
||||||
|
arr.forEach((el: unknown) => writer.write(el))
|
||||||
|
writer.close()
|
||||||
yield* readable
|
yield* readable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,7 +251,7 @@ client.on('messageCreate', async (msg: Message) => {
|
||||||
let buf = 'Roles:'
|
let buf = 'Roles:'
|
||||||
if (msg.member === undefined) return
|
if (msg.member === undefined) return
|
||||||
for await (const role of msg.member.roles) {
|
for await (const role of msg.member.roles) {
|
||||||
buf += `\n${role.name}`
|
buf += `\n${role.name === '@everyone' ? 'everyone' : role.name}`
|
||||||
}
|
}
|
||||||
msg.reply(buf)
|
msg.reply(buf)
|
||||||
} else if (msg.content === '!timer') {
|
} else if (msg.content === '!timer') {
|
||||||
|
|
Loading…
Reference in a new issue