mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Added pinging bot for prefix and var string prefix
This commit is contained in:
		
							parent
							
								
									a86e11ed23
								
							
						
					
					
						commit
						77422538df
					
				
					 4 changed files with 16 additions and 4 deletions
				
			
		|  | @ -28,7 +28,7 @@ const responses = [ | ||||||
| export default new Command({ | export default new Command({ | ||||||
| 	description: "Fun commands.", | 	description: "Fun commands.", | ||||||
| 	endpoint: false, | 	endpoint: false, | ||||||
| 	run: "Please provide an argument.\nFor help, run `.help fun`.", | 	run: "Please provide an argument.\nFor help, run `%prefix%help fun`.", | ||||||
| 	subcommands: | 	subcommands: | ||||||
| 	{ | 	{ | ||||||
| 		"8ball": new Command({ | 		"8ball": new Command({ | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ import {Collection} from "discord.js"; | ||||||
| import {generateHandler} from "./storage"; | import {generateHandler} from "./storage"; | ||||||
| import {promises as ffs, existsSync, writeFile} from "fs"; | import {promises as ffs, existsSync, writeFile} from "fs"; | ||||||
| import {PERMISSIONS} from "./permissions"; | import {PERMISSIONS} from "./permissions"; | ||||||
|  | import {getPrefix} from "../core/structures"; | ||||||
| 
 | 
 | ||||||
| interface CommandOptions | interface CommandOptions | ||||||
| { | { | ||||||
|  | @ -52,7 +53,8 @@ export default class Command | ||||||
| 		if(isType(this.run, String)) | 		if(isType(this.run, String)) | ||||||
| 		{ | 		{ | ||||||
| 			$.channel.send(parseVars(this.run as string, { | 			$.channel.send(parseVars(this.run as string, { | ||||||
| 				author: $.author.toString() | 				author: $.author.toString(), | ||||||
|  | 				prefix: getPrefix($.guild) | ||||||
| 			}, "???")); | 			}, "???")); | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| import FileManager from "./storage"; | import FileManager from "./storage"; | ||||||
| import $, {select, GenericJSON, GenericStructure} from "./lib"; | import $, {select, GenericJSON, GenericStructure} from "./lib"; | ||||||
| import {watch} from "fs"; | import {watch} from "fs"; | ||||||
|  | import {Guild as DiscordGuild} from "discord.js"; | ||||||
| 
 | 
 | ||||||
| class ConfigStructure extends GenericStructure | class ConfigStructure extends GenericStructure | ||||||
| { | { | ||||||
|  | @ -114,4 +115,9 @@ if(process.argv[2] === "dev") | ||||||
| 			case "storage": Storage = new StorageStructure(FileManager.read("storage")); break; | 			case "storage": Storage = new StorageStructure(FileManager.read("storage")); break; | ||||||
| 		} | 		} | ||||||
| 	}); | 	}); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export function getPrefix(guild: DiscordGuild|null): string | ||||||
|  | { | ||||||
|  | 	return Storage.getGuild(guild?.id || "N/A").prefix ?? Config.prefix; | ||||||
| } | } | ||||||
|  | @ -3,7 +3,7 @@ import Command, {loadCommands} from "../core/command"; | ||||||
| import {hasPermission, getPermissionLevel, PermissionNames} from "../core/permissions"; | import {hasPermission, getPermissionLevel, PermissionNames} from "../core/permissions"; | ||||||
| import $ from "../core/lib"; | import $ from "../core/lib"; | ||||||
| import {Message, Permissions, Collection} from "discord.js"; | import {Message, Permissions, Collection} from "discord.js"; | ||||||
| import {Config, Storage} from "../core/structures"; | import {getPrefix} from "../core/structures"; | ||||||
| 
 | 
 | ||||||
| // It's a rather hacky solution, but since there's no top-level await, I just have to make the loading conditional.
 | // It's a rather hacky solution, but since there's no top-level await, I just have to make the loading conditional.
 | ||||||
| let commands: Collection<string, Command>|null = null; | let commands: Collection<string, Command>|null = null; | ||||||
|  | @ -19,10 +19,14 @@ export default new Event({ | ||||||
| 		if(message.author.bot) | 		if(message.author.bot) | ||||||
| 			return; | 			return; | ||||||
| 		 | 		 | ||||||
| 		const prefix = Storage.getGuild(message.guild?.id || "N/A").prefix || Config.prefix; | 		const prefix = getPrefix(message.guild); | ||||||
| 		 | 		 | ||||||
| 		if(!message.content.startsWith(prefix)) | 		if(!message.content.startsWith(prefix)) | ||||||
|  | 		{ | ||||||
|  | 			if(message.client.user && message.mentions.has(message.client.user)) | ||||||
|  | 				message.channel.send(`${message.author.toString()}, my prefix on this guild is \`${prefix}\`.`); | ||||||
| 			return; | 			return; | ||||||
|  | 		} | ||||||
| 		 | 		 | ||||||
| 		const [header, ...args] = message.content.substring(prefix.length).split(/ +/); | 		const [header, ...args] = message.content.substring(prefix.length).split(/ +/); | ||||||
| 		 | 		 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue