12 * The email address(es) to send the email to. Only available to Val Town Pro subscribers.
13 * Can be a single string, IAddress object, or an array of strings/IAddress objects.
14 * @default the email of the logged user calling this function.
15 */
16 to?: (IAddress | string)[] | IAddress | string;
22const rest = new REST({ version: "9" }).setToken(process.env.DISCORD_BOT_TOKEN);
23
24async function findUserVoiceChannel(guildId, userId) {
25 try {
26 const channels = await rest.get(Routes.guildChannels(guildId));
39}
40
41async function sayMessage(guildId, channelId, message) {
42 const url = googleTTS.getAudioUrl(message, {
43 lang: "en",
68}
69
70function createDiscordJSAdapter(channelId, guildId) {
71 return {
72 sendPayload: (payload) => {
1Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality
89];
90
91async function getCurrentTopic() {
92 const storedTopic = await blob.getJSON("currentTopic");
93 if (storedTopic && new Date(storedTopic.expiresAt) > new Date()) {
105}
106
107function TopicDisplay({ topic, expiresAt }) {
108 const expirationDate = new Date(expiresAt);
109 const timeRemaining = expirationDate - new Date();
130}
131
132export default async function server(req: Request): Promise<Response> {
133 const currentTopic = await getCurrentTopic();
134 const { renderToString } = await import("https://esm.sh/react-dom/server");
236}
237
238function transformIntoDatabaseSession(raw: SessionSchema): DatabaseSession {
239 const { id, user_id: userId, expires_at: expiresAtUnix, ...attributes } = raw;
240 return {
246}
247
248function transformIntoDatabaseUser(raw: UserSchema): DatabaseUser {
249 const { id, ...attributes } = raw;
250 return {
254}
255
256function escapeName(val: string): string {
257 return "`" + val + "`";
258}
259
260// Helper functions
261export async function createTables(userTable: string, sessionTable: string) {
262 return sqlite.batch([
263 `CREATE TABLE IF NOT EXISTS ${userTable} (
277}
278
279export async function createUser({ userTable, sessionTable, username, password, github_id, google_id }: {
280 userTable: string;
281 sessionTable: string;
299}
300
301export async function getUser(
302 { userTable, username, github_id, google_id }: {
303 userTable: string;
330}
331
332export async function verifyPassword(hashed_password: string, password: string): Promise<boolean> {
333 return new Scrypt().verify(hashed_password, password);
334}
6 webhook_url: string = process.env.discord_webhook,
7) => {
8 function chunkString(str) {
9 const chunks = [];
10 let startIndex = 0;
1# Send Chunked Discord Message
2This function is used to send a message to a Discord webhook. If the message exceeds the maximum character limit (2000 characters), it will be divided into chunks and sent as multiple messages.
3
4### Parameters
5message (string): The message to be sent to the Discord webhook.
6### Return Value
7This function does not return any value.
8
9## Example Usage:
13await @ktodaz.sendDiscordMessage(message);
14```
15In the above example, the sendDiscordMessage function is used to send the message to the Discord webhook. If the message exceeds 2000 characters, it will be split into smaller chunks and sent as separate messages.
16
17## Required Secrets:
1# Send Chunked Discord Message
2This function is used to send a message to a Discord webhook. If the message exceeds the maximum character limit (2000 characters), it will be divided into chunks and sent as multiple messages.
3
4### Parameters
5message (string): The message to be sent to the Discord webhook.
6### Return Value
7This function does not return any value.
8
9## Example Usage:
13await @ktodaz.sendDiscordMessage(message);
14```
15In the above example, the sendDiscordMessage function is used to send the message to the Discord webhook. If the message exceeds 2000 characters, it will be split into smaller chunks and sent as separate messages.
16
17## Required Secrets:
6 webhook_url: string = process.env.discord_webhook,
7) => {
8 function chunkString(str) {
9 const chunks = [];
10 let startIndex = 0;
22const rest = new REST({ version: "9" }).setToken(process.env.DISCORD_BOT_TOKEN);
23
24async function findUserVoiceChannel(guildId, userId) {
25 try {
26 const channels = await rest.get(Routes.guildChannels(guildId));
39}
40
41async function sayMessage(guildId, channelId, message) {
42 const url = googleTTS.getAudioUrl(message, {
43 lang: "en",
68}
69
70function createDiscordJSAdapter(channelId, guildId) {
71 return {
72 sendPayload: (payload) => {