Raiha is a simple, easy-to use bot whose core focus is making alt text easier to write and use.
Discord currently doesn't allow you to edit or add alt text once your message has been sent. With Raiha, however, you can reply to the message you want to add alt text to, and Raiha will repost your message (including reply status and @mentions) with the alt text you wanted.
Adding alt text to someone else's message works exactly the same as adding after-the-fact alt text to your own message. This is useful if someone doesn't add alt text, or if their alt text is inaccurate or lacking detail. Raiha will repost the message, including a blurb saying who wrote the original message, and who added the alt text. This helps with accountability and keeps everyone aware of what repost is what.
You can use Raiha on a message you haven't sent yet by including a trigger at the end of the message body, triggering an automatic repost with the specified alt text. This is useful if you want to use some of Raiha's more advanced features, or if you just want to bypass Discord's native alt text input box.
Raiha comes with out-of-the-box support for Azure computer vision, namely Image Descriptions and Optical Character Recognition (OCR). These features allow you to automatically write basic image descriptions and/or include the text content of an image.
Raiha will react to messages that are missing alt text. By default, the ❌ emoji is used, but this can be changed in the server settings. This reaction allows for easy distinction between messages with and without alt text, even when Discord's alt text display feature is disabled in your client.
Why not gamify accessibility? Raiha comes with three leaderboards:
- Native - This leaderboard keeps track of the number of messages sent using Discord's built-in alt text feature
- Raiha - This leaderboard keeps track of the number of Raiha reposts triggered
- Loserboard - This leaderboard keeps track of the number of messages sent without alt text. Using Raiha to repost your own message will decrement this board.
A bit more on the Loserboard: The loserboard can be configured to notify moderators in a mod channel when a user's Loserboard score reaches certain thresholds. What you do with this information is up to you. One suggestion: an Image Mute.
There are several settings that users can set on themselves. Each user setting is a boolean value, either ON or OFF.
- Reminder - Posts a mini-tutorial each time the user forgets to use alt text
- Activation Failure - A meme setting; posts a gif when the user attempts to activate Raiha but fails
- Auto - Automatically run Raiha on any images missing alt text when the message is sent
All Raiha reposts begin with a trigger. Currently-accepted triggers are r!
(alias: !r
), alt:
, and id:
. Servers can disable individual triggers if they want/need to.
- Add alt text to an existing message - Reply to the message, beginning with a trigger, then the alt text you want to apply
- ex:
r! Tabby kitten sitting in a sink
- ex:
- Add alt text to a new message - Write a message as normal, then add a trigger and alt text at the end
- ex:
I had a lot of fun at the beach yesterday. id: sunset over the ocean
- ex:
- Multiple images - Use the vertical pipe character
|
to separate alt texts- ex:
r! cat sitting on stairs | dog sitting on stairs
- ex:
- Computer Vision
- Image Description - Use
$$
as the alt text. ex:r! $$
- Image Description and OCR - Use
$$ocr
as the alt text. ex:r! $$ocr
- Your Description and OCR - Supply your own description, plus
$$ocr
. ex:letter in the mail $$ocr
- NOTE: Computer vision commands can be mixed and matched, and are applied per-image
- ex:
r! a bunny | $$ocr | $$ | my report card $$ocr
- ex:
- Image Description - Use
- Edit Reposted Message
- Whole message - Reply to the message with the trigger word
edit!
followed by the new message body - Typo correction - Reply to the message with the sed-like syntax
r/old/new
, whereold
will be replaced bynew
- ex:
This is my mom's dog, Bingo.
+r/mom/dad
=This is my dad's dog, Bingo.
- ex:
- NOTE: Edits can only be performed on messages with a message body. You cannot retroactively add a message body.
- Whole message - Reply to the message with the trigger word
- Delete Reposted Message - Reply to the message with the trigger word
delete!
Edit and Delete commands will only work if you are the original poster of the message, regardless who initiated the repost.
- Note: Raiha has been tested using
Node 21.4.0
- Raiha requires a Firebase Real-Time Database for logging and leaderboards. The base tier is free, and it is highly unlikely Raiha will ever generate enough data to exceed the base tier.
- Raiha also requires an Azure Cognitive Vision Service instance. The base tier is free, and allows for 20 requests per minute, and 5000 per month.
- Optionally, Raiha can use GPT-4 with vision. This is a paid service, but by using the
low
detail setting, expenses can be mitigated. If this feature is not being used, ensure that theopenai
guild configuration option is set tofalse
. ffprobe
must be installed for audio transcriptions to work.
- Clone the Raiha repository
- Create a Discord Bot Application and note the API token
- Set up a Firebase project with a Realtime Database
- Download the
firebase.json
file from Firebase (hint: create an app in the firebase console) - Create an Azure account, set up Azure Vision Services, and note the URL for it
- Create a
.env
file in the project root and add the following to it:
TOKEN=[yourtoken]
DATABASE_URL=[databaseurl]
CV_API_KEY=[yourkey]
CV_ENDPOINT=[endpoint, with trailing /]
OPENAI_API_KEY=[yourkey]
- Place your
firebase.json
in the/src/
folder. - In the firebase database, set the guild configuration for your server at
/Configuration/[guildID]
:
{
ai: boolean,
altrules: "default" | string,
autoPunishment: boolean,
autoPunishmentFormula: string (Formula to get minutes, where `x` is the loserboard value. Ex: "(x == 10) ? (60 * 12) : (x / 10 * 60 * 24)"),
autoPunishmentRole: string (roleID),
enableWarnings: boolean,
errorChannel: string (channelID),
errorMismatch: "default" | string (emojiID),
errorNoAlt: "default" | string (emojiID),
errorNotReply: "default" | string (emojiID),
greenThreshold: number,
leaderboard: boolean,
loserboard: boolean,
modChannel: string (channelID),
modRole: int (roleId),
muteThreshold: number (0 to disable),
specialWarnThresholds: number[] (ignores enableWarnings value),
placeInMessageBodyMode: "off" | "all" | "description",
disabledTriggers: string[] | undefined,
openai: boolean,
autoModeOptOut: boolean,
linkedImageLoserboard: boolean
}
Some of these options are not yet implemented. Data types and names may change.
Pull requests are always welcome.
Raiha is licensed under LGPL v3.0.
© 2022–2023 9volt.