Skip to content

Commit

Permalink
gifs (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Jun 9, 2023
1 parent 35c0366 commit 0d5a323
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
},
"dependencies": {
"@effect-http/client": "^0.27.0",
"@effect/data": "^0.12.4",
"@effect/data": "^0.12.5",
"@effect/io": "^0.26.0",
"@effect/schema": "^0.20.0",
"@effect/schema": "^0.20.1",
"@effect/stream": "^0.22.0",
"dfx": "^0.48.0",
"dotenv": "^16.1.3",
"dotenv": "^16.1.4",
"effect-schema-class": "^0.4.0",
"html-entities": "^2.3.3",
"html-entities": "^2.3.5",
"openai": "^3.2.1",
"prettier": "^2.8.8"
}
Expand Down
48 changes: 24 additions & 24 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/NoEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Discord, DiscordREST } from "dfx"
import { DiscordGateway } from "dfx/gateway"

class NotValidMessageError extends Data.TaggedClass("NotValidMessageError")<{
readonly reason: "disabled" | "no-embed"
readonly reason: "disabled" | "no-embed" | "gif"
}> {}

export interface NoEmbedOptions {
Expand Down Expand Up @@ -49,6 +49,10 @@ const make = ({ topicKeyword }: NoEmbedOptions) =>
message.content.includes(message.embeds[0].url),
() => new NotValidMessageError({ reason: "no-embed" }),
),
Effect.filterOrFail(
({ message }) => message.embeds[0].type !== Discord.EmbedType.GIFV,
() => new NotValidMessageError({ reason: "gif" }),
),
Effect.flatMap(({ message }) =>
rest.editMessage(message.channel_id, message.id, {
flags: Number(message.flags) | Discord.MessageFlag.SUPPRESS_EMBEDS,
Expand Down

0 comments on commit 0d5a323

Please sign in to comment.