diff --git a/.husky/pre-commit b/.husky/pre-commit
old mode 100644
new mode 100755
diff --git a/src/commands/utility/streaminfo.ts b/src/commands/utility/streaminfo.ts
index 969e668..c1a0c9d 100644
--- a/src/commands/utility/streaminfo.ts
+++ b/src/commands/utility/streaminfo.ts
@@ -8,8 +8,15 @@ export default new NamedCommand({
if (streamList.has(userID)) {
const stream = streamList.get(userID)!;
- stream.description = args.join(" ") || "No description set.";
+ const description = args.join(" ") || "No description set.";
+ stream.description = description;
stream.update();
+ channel.send(`Successfully set the stream description to:`, {
+ embed: {
+ description,
+ color: member!.displayColor
+ }
+ });
} else {
// Alternatively, I could make descriptions last outside of just one stream.
channel.send("You can only use this command when streaming.");
diff --git a/src/index.ts b/src/index.ts
index 95befe7..863569e 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -69,7 +69,7 @@ import "./modules/ready";
import "./modules/presence";
import "./modules/lavalink";
import "./modules/emoteRegistry";
-import "./modules/channelListener";
+import "./modules/systemInfo";
import "./modules/intercept";
import "./modules/messageEmbed";
import "./modules/guildMemberAdd";
diff --git a/src/lib.test.ts b/src/lib.test.ts
index 0cd4cc9..b9990b3 100644
--- a/src/lib.test.ts
+++ b/src/lib.test.ts
@@ -1,5 +1,5 @@
import {strict as assert} from "assert";
-import {pluralise, pluraliseSigned, replaceAll, toTitleCase, split} from "./lib";
+import {pluralise, pluraliseSigned, replaceAll, toTitleCase, split, parseVars} from "./lib";
// I can't figure out a way to run the test suite while running the bot.
describe("Wrappers", () => {
@@ -52,6 +52,12 @@ describe("Wrappers", () => {
});
});
+ describe("#parseVars()", () => {
+ it('should replace %test% with "yeet"', () => {
+ assert.strictEqual(parseVars("ya %test%", {test: "yeet"}), "ya yeet");
+ });
+ });
+
describe("#toTitleCase()", () => {
it("should capitalize the first letter of each word", () => {
assert.strictEqual(
diff --git a/src/modules/channelListener.ts b/src/modules/channelListener.ts
deleted file mode 100644
index 910d1ab..0000000
--- a/src/modules/channelListener.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import {client} from "../index";
-import {GuildChannel} from "discord.js";
-
-client.on("channelCreate", async (channel) => {
- const botGuilds = client.guilds;
-
- if (channel instanceof GuildChannel) {
- const createdGuild = await botGuilds.fetch(channel.guild.id);
- console.log(`Channel created in '${createdGuild.name}' called '#${channel.name}'`);
- }
-});
-
-client.on("channelDelete", async (channel) => {
- const botGuilds = client.guilds;
-
- if (channel instanceof GuildChannel) {
- const createdGuild = await botGuilds.fetch(channel.guild.id);
- console.log(`Channel deleted in '${createdGuild.name}' called '#${channel.name}'`);
- }
-});
diff --git a/src/modules/emoteRegistry.ts b/src/modules/emoteRegistry.ts
index 88ab099..a3de8bc 100644
--- a/src/modules/emoteRegistry.ts
+++ b/src/modules/emoteRegistry.ts
@@ -1,7 +1,6 @@
import {client} from "../index";
import FileManager from "./storage";
-import {EmoteRegistryDump, Config} from "../structures";
-import {TextChannel} from "discord.js";
+import {EmoteRegistryDump} from "../structures";
function updateGlobalEmoteRegistry(): void {
const data: EmoteRegistryDump = {version: 1, list: []};
@@ -39,43 +38,13 @@ client.on("emojiUpdate", () => {
updateGlobalEmoteRegistry();
});
-client.on("guildCreate", (guild) => {
- console.log(
- `[GUILD JOIN] ${guild.name} (${guild.id}) added the bot. Owner: ${guild.owner!.user.tag} (${
- guild.owner!.user.id
- }). Updated emote registry.`
- );
-
- if (Config.systemLogsChannel) {
- const channel = client.channels.cache.get(Config.systemLogsChannel);
-
- if (channel && channel.type === "text") {
- (channel as TextChannel).send(
- `TravBot joined: \`${guild.name}\`. The owner of this guild is: \`${guild.owner!.user.tag}\` (\`${
- guild.owner!.user.id
- }\`)`
- );
- } else {
- console.warn(`${Config.systemLogsChannel} is not a valid text channel for system logs!`);
- }
- }
-
+client.on("guildCreate", () => {
+ console.log("Updated emote registry.");
updateGlobalEmoteRegistry();
});
-client.on("guildDelete", (guild) => {
- console.log(`[GUILD LEAVE] ${guild.name} (${guild.id}) removed the bot. Updated emote registry.`);
-
- if (Config.systemLogsChannel) {
- const channel = client.channels.cache.get(Config.systemLogsChannel);
-
- if (channel && channel.type === "text") {
- (channel as TextChannel).send(`\`${guild.name}\` (\`${guild.id}\`) removed the bot.`);
- } else {
- console.warn(`${Config.systemLogsChannel} is not a valid text channel for system logs!`);
- }
- }
-
+client.on("guildDelete", () => {
+ console.log("Updated emote registry.");
updateGlobalEmoteRegistry();
});
diff --git a/src/modules/messageEmbed.test.ts b/src/modules/messageEmbed.test.ts
index 3508de2..8d70866 100644
--- a/src/modules/messageEmbed.test.ts
+++ b/src/modules/messageEmbed.test.ts
@@ -1,55 +1,49 @@
jest.useFakeTimers();
import {strict as assert} from "assert";
-//import {extractFirstMessageLink} from "./messageEmbed";
+import {extractFirstMessageLink} from "./messageEmbed";
-/*describe("modules/messageEmbed", () => {
- describe("extractFirstMessageLink()", () => {
- const guildID = "802906483866631183";
- const channelID = "681747101169682147"
- const messageID = "996363055050949479";
- const post = `channels/${guildID}/${channelID}/${messageID}`;
- const commonUrl = `https://discord.com/channels/${post}`;
- const combined = [guildID, channelID, messageID];
+describe("modules/messageEmbed", () => {
+ describe("extractFirstMessageLink()", () => {
+ const guildID = "802906483866631183";
+ const channelID = "681747101169682147";
+ const messageID = "996363055050949479";
+ const post = `channels/${guildID}/${channelID}/${messageID}`;
+ const commonUrl = `https://discord.com/${post}`;
+ const combined = [guildID, channelID, messageID];
- it('should return work and extract correctly on an isolated link', () => {
- const result = extractFirstMessageLink(commonUrl);
- assert.deepStrictEqual(result, combined);
- })
+ it("should return work and extract correctly on an isolated link", () => {
+ const result = extractFirstMessageLink(commonUrl);
+ assert.deepStrictEqual(result, combined);
+ });
- it('should return work and extract correctly on a link within a message', () => {
- const result = extractFirstMessageLink(`sample text${commonUrl}, more sample text`);
- assert.deepStrictEqual(result, combined);
- })
+ it("should return work and extract correctly on a link within a message", () => {
+ const result = extractFirstMessageLink(`sample text${commonUrl}, more sample text`);
+ assert.deepStrictEqual(result, combined);
+ });
- it('should return null on "!link"', () => {
- const result = extractFirstMessageLink(`just some !${commonUrl} text`);
- assert.strictEqual(result, null);
- })
+ it('should return null on "!link"', () => {
+ const result = extractFirstMessageLink(`just some !${commonUrl} text`);
+ assert.strictEqual(result, null);
+ });
- it('should return null on ""', () => {
- const result = extractFirstMessageLink(`just some <${commonUrl}> text`);
- assert.strictEqual(result, null);
- })
+ it('should return null on ""', () => {
+ const result = extractFirstMessageLink(`just some <${commonUrl}> text`);
+ assert.strictEqual(result, null);
+ });
- it('should return work and extract correctly on " {
- const result = extractFirstMessageLink(`just some <${commonUrl} text`);
- assert.deepStrictEqual(result, combined);
- })
+ it('should return work and extract correctly on " {
+ const result = extractFirstMessageLink(`just some <${commonUrl} text`);
+ assert.deepStrictEqual(result, combined);
+ });
- it('should return work and extract correctly on "link>"', () => {
- const result = extractFirstMessageLink(`just some ${commonUrl}> text`);
- assert.deepStrictEqual(result, combined);
- })
+ it('should return work and extract correctly on "link>"', () => {
+ const result = extractFirstMessageLink(`just some ${commonUrl}> text`);
+ assert.deepStrictEqual(result, combined);
+ });
- it('should return work and extract correctly on a canary link', () => {
- const result = extractFirstMessageLink(`https://canary.discord.com/${post}`);
- assert.deepStrictEqual(result, combined);
- })
- })
-});*/
-
-describe("placeholder", () => {
- it("placeholder", async () => {
- assert.strictEqual(1, 1);
+ it("should return work and extract correctly on a canary link", () => {
+ const result = extractFirstMessageLink(`https://canary.discord.com/${post}`);
+ assert.deepStrictEqual(result, combined);
+ });
});
});
diff --git a/src/modules/systemInfo.ts b/src/modules/systemInfo.ts
new file mode 100644
index 0000000..f9a0b64
--- /dev/null
+++ b/src/modules/systemInfo.ts
@@ -0,0 +1,57 @@
+import {client} from "../index";
+import {GuildChannel, TextChannel} from "discord.js";
+import {Config} from "../structures";
+
+client.on("channelCreate", async (channel) => {
+ const botGuilds = client.guilds;
+
+ if (channel instanceof GuildChannel) {
+ const createdGuild = await botGuilds.fetch(channel.guild.id);
+ console.log(`Channel created in '${createdGuild.name}' called '#${channel.name}'`);
+ }
+});
+
+client.on("channelDelete", async (channel) => {
+ const botGuilds = client.guilds;
+
+ if (channel instanceof GuildChannel) {
+ const createdGuild = await botGuilds.fetch(channel.guild.id);
+ console.log(`Channel deleted in '${createdGuild.name}' called '#${channel.name}'`);
+ }
+});
+
+client.on("guildCreate", (guild) => {
+ console.log(
+ `[GUILD JOIN] ${guild.name} (${guild.id}) added the bot. Owner: ${guild.owner!.user.tag} (${
+ guild.owner!.user.id
+ }).`
+ );
+
+ if (Config.systemLogsChannel) {
+ const channel = client.channels.cache.get(Config.systemLogsChannel);
+
+ if (channel && channel.type === "text") {
+ (channel as TextChannel).send(
+ `TravBot joined: \`${guild.name}\`. The owner of this guild is: \`${guild.owner!.user.tag}\` (\`${
+ guild.owner!.user.id
+ }\`)`
+ );
+ } else {
+ console.warn(`${Config.systemLogsChannel} is not a valid text channel for system logs!`);
+ }
+ }
+});
+
+client.on("guildDelete", (guild) => {
+ console.log(`[GUILD LEAVE] ${guild.name} (${guild.id}) removed the bot.`);
+
+ if (Config.systemLogsChannel) {
+ const channel = client.channels.cache.get(Config.systemLogsChannel);
+
+ if (channel && channel.type === "text") {
+ (channel as TextChannel).send(`\`${guild.name}\` (\`${guild.id}\`) removed the bot.`);
+ } else {
+ console.warn(`${Config.systemLogsChannel} is not a valid text channel for system logs!`);
+ }
+ }
+});