Skip to content

Commit

Permalink
remove rest response .asUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Feb 16, 2024
1 parent 6348c07 commit e37d4ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/DiscordREST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const make = Effect.gen(function* (_) {
})

class RestResponseImpl<T>
extends Effectable.Class<ResponseWithData<T>, DiscordRESTError, Scope>
extends Effectable.Class<ResponseWithData<T>, DiscordRESTError>
implements RestResponse<T>
{
constructor(
Expand All @@ -269,16 +269,16 @@ class RestResponseImpl<T>
super()
}

commit(): Effect.Effect<ResponseWithData<T>, DiscordRESTError, Scope> {
return this.response
commit(): Effect.Effect<ResponseWithData<T>, DiscordRESTError> {
return Effect.scoped(this.response)
}

get json() {
return Effect.scoped(Effect.flatMap(this.response, _ => _.json))
}

get asUnit() {
return Effect.scoped(this.response)
get response() {
return this.response
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/DiscordREST/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface ResponseWithData<A> extends Http.response.ClientResponse {
}

export interface RestResponse<T>
extends Effect.Effect<ResponseWithData<T>, DiscordRESTError, Scope> {
extends Effect.Effect<ResponseWithData<T>, DiscordRESTError> {
readonly json: Effect.Effect<T, DiscordRESTError | Http.error.ResponseError>
readonly asUnit: Effect.Effect<void, DiscordRESTError>
readonly response: Effect.Effect<ResponseWithData<T>, DiscordRESTError, Scope>
}
16 changes: 7 additions & 9 deletions src/Interactions/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,15 @@ export const run =
GlobalApplicationCommand.map(_ => _.command),
),
},
).asUnit
)

const guildSync = GuildApplicationCommand.length
? gateway.handleDispatch(
"GUILD_CREATE",
a =>
rest.bulkOverwriteGuildApplicationCommands(
application.id,
a.id,
GuildApplicationCommand.map(_ => _.command) as any,
).asUnit,
? gateway.handleDispatch("GUILD_CREATE", a =>
rest.bulkOverwriteGuildApplicationCommands(
application.id,
a.id,
GuildApplicationCommand.map(_ => _.command) as any,
),
)
: Effect.never

Expand Down

0 comments on commit e37d4ab

Please sign in to comment.