mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Merge branch 'typescript' of https://github.com/keanuplayz/TravBot-v3 into omnibus
This commit is contained in:
		
						commit
						bd67f3b8cc
					
				
					 8 changed files with 115 additions and 102 deletions
				
			
		
							
								
								
									
										0
									
								
								.husky/pre-commit
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								.husky/pre-commit
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -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."); | ||||
|  |  | |||
|  | @ -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"; | ||||
|  |  | |||
|  | @ -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( | ||||
|  |  | |||
|  | @ -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}'`); | ||||
|     } | ||||
| }); | ||||
|  | @ -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(); | ||||
| }); | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 "<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 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 "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); | ||||
|         }); | ||||
|     }); | ||||
| }); | ||||
|  |  | |||
							
								
								
									
										57
									
								
								src/modules/systemInfo.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								src/modules/systemInfo.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -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!`); | ||||
|         } | ||||
|     } | ||||
| }); | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue