Skip to content

Commit

Permalink
removed usage of sb.Config from .mts files
Browse files Browse the repository at this point in the history
  • Loading branch information
Supinic committed Sep 29, 2024
1 parent 200d1f2 commit e06e778
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion @types/classes/command.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ export declare class Command extends ClassTemplate {
getDynamicDescription: () => Promise<string[] | null>;

/**
* Creates the command's detail URL based on a Configuration variable
* Creates the command's detail URL based on a configuration value
* @param options
* @param options.useCodePath If true, returns a path for the command's code description
*/
Expand Down
2 changes: 0 additions & 2 deletions @types/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ declare var sb: {
Date: core.Date,
Error: core.Error,
Promise: core.Promise,

Config: core.Config,
Got: core.Got,
// TODO add others
}
7 changes: 2 additions & 5 deletions gots/github/index.mts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { Config } from "supi-core";

export const definition = {
name: "GitHub",
optionsType: "function",
options: (() => {
if (!Config.has("API_GITHUB_KEY", true)) {
if (!process.env.API_GITHUB_KEY) {
return {
prefixUrl: "https://api.github.com"
};
}

const token = Config.get("API_GITHUB_KEY", true);
return {
prefixUrl: "https://api.github.com",
headers: {
Authorization: `Bearer ${token}`
Authorization: `Bearer ${process.env.API_GITHUB_KEY}`
}
};
}),
Expand Down
6 changes: 2 additions & 4 deletions gots/supibot/index.mts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Config } from "supi-core";

export const definition = {
name: "Supibot",
optionsType: "function",
options: (() => {
const secure = Config.get("SUPIBOT_API_SECURE", false) ?? false;
const secure = process.env.SUPIBOT_API_SECURE ?? false;
const protocol = (secure) ? "https" : "http";
const port = Config.get("SUPIBOT_API_PORT", false) ?? 80;
const port = process.env.SUPIBOT_API_PORT ?? 80;

return {
prefixUrl: `${protocol}://localhost:${port}`
Expand Down
24 changes: 11 additions & 13 deletions gots/twitch-gql/index.mts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { Config } from "supi-core";
const list = [
"TWITCH_GQL_OAUTH",
"TWITCH_GQL_CLIENT_ID",
"TWITCH_GQL_CLIENT_VERSION",
"TWITCH_GQL_DEVICE_ID"
];

export const definition = {
name: "TwitchGQL",
optionsType: "function",
options: (() => {
const list = [
"TWITCH_GQL_OAUTH",
"TWITCH_GQL_CLIENT_ID",
"TWITCH_GQL_CLIENT_VERSION",
"TWITCH_GQL_DEVICE_ID"
];

if (list.some(i => !Config.has(i, true))) {
if (list.some(key => !process.env[key])) {
throw new Error("Twitch GQL sb.Got instance cannot initialize - missing configuration variable(s)");
}

Expand All @@ -22,12 +20,12 @@ export const definition = {
headers: {
Accept: "*/*",
"Accept-Language": "en-US",
Authorization: `OAuth ${Config.get("TWITCH_GQL_OAUTH")}`,
"Client-ID": Config.get("TWITCH_GQL_CLIENT_ID"),
"Client-Version": Config.get("TWITCH_GQL_CLIENT_VERSION"),
Authorization: `OAuth ${process.env.TWITCH_GQL_OAUTH}`,
"Client-ID": process.env.TWITCH_GQL_CLIENT_ID,
"Client-Version": process.env.TWITCH_GQL_CLIENT_VERSION,
"Content-Type": "text/plain;charset=UTF-8",
Referer: "https://www.twitch.tv",
"X-Device-ID": Config.get("TWITCH_GQL_DEVICE_ID")
"X-Device-ID": process.env.TWITCH_GQL_DEVICE_ID
}
};
}),
Expand Down
2 changes: 1 addition & 1 deletion init/definitions/chat_data/tables/Channel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS `chat_data`.`Channel` (
`Logging` SET('Lines','Meta') NULL DEFAULT 'Lines,Meta' COLLATE 'utf8mb4_general_ci',
`Banphrase_API_Type` ENUM('Pajbot') DEFAULT NULL COMMENT 'If a channel should use an external banphrase API, this should be its type. Currently only supports "Pajbot".',
`Banphrase_API_URL` VARCHAR(100) DEFAULT NULL COMMENT 'If a channel should use an external banphrase API, this should be its bare URL - no https:// or endpoints',
`Banphrase_API_Downtime` enum('Ignore','Notify','Nothing','Refuse','Whisper') DEFAULT NULL COMMENT 'Determines the behaviour the bot should take if the banphrase API times out.\r\nIgnore - acts as if nothing happened and posts the message as is.\r\nNotify - same as Ignore, but adds a warning emoji\r\nRefuse - bot will refuse to reply with a warning message set up in Config',
`Banphrase_API_Downtime` enum('Ignore','Notify','Nothing','Refuse','Whisper') DEFAULT NULL COMMENT 'Determines the behaviour the bot should take if the banphrase API times out.\r\nIgnore - acts as if nothing happened and posts the message as is.\r\nNotify - same as Ignore, but adds a warning emoji\r\nRefuse - bot will refuse to reply with a warning message set up in config',
`Message_Limit` SMALLINT(5) UNSIGNED DEFAULT NULL COMMENT 'If not NULL, this determines the maximum length of a message in said channel. If NULL, will use Platform defaults.',
`Mirror` INT(10) UNSIGNED DEFAULT NULL COMMENT 'If not NULL, will mirror all messages from this channel to channel specified in Mirror.',
`Description` TEXT DEFAULT NULL,
Expand Down

0 comments on commit e06e778

Please sign in to comment.