fix async iterator

This commit is contained in:
DjDeveloperr 2021-04-04 19:16:34 +05:30
parent 1e53d7d770
commit 5e65673107
3 changed files with 7 additions and 3 deletions

View file

@ -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
} }

View file

@ -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
} }

View file

@ -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') {