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({ | ||||
| 	description: "Fun commands.", | ||||
| 	endpoint: false, | ||||
| 	run: "Please provide an argument.\nFor help, run `.help fun`.", | ||||
| 	run: "Please provide an argument.\nFor help, run `%prefix%help fun`.", | ||||
| 	subcommands: | ||||
| 	{ | ||||
| 		"8ball": new Command({ | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ import {Collection} from "discord.js"; | |||
| import {generateHandler} from "./storage"; | ||||
| import {promises as ffs, existsSync, writeFile} from "fs"; | ||||
| import {PERMISSIONS} from "./permissions"; | ||||
| import {getPrefix} from "../core/structures"; | ||||
| 
 | ||||
| interface CommandOptions | ||||
| { | ||||
|  | @ -52,7 +53,8 @@ export default class Command | |||
| 		if(isType(this.run, String)) | ||||
| 		{ | ||||
| 			$.channel.send(parseVars(this.run as string, { | ||||
| 				author: $.author.toString() | ||||
| 				author: $.author.toString(), | ||||
| 				prefix: getPrefix($.guild) | ||||
| 			}, "???")); | ||||
| 		} | ||||
| 		else | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| import FileManager from "./storage"; | ||||
| import $, {select, GenericJSON, GenericStructure} from "./lib"; | ||||
| import {watch} from "fs"; | ||||
| import {Guild as DiscordGuild} from "discord.js"; | ||||
| 
 | ||||
| class ConfigStructure extends GenericStructure | ||||
| { | ||||
|  | @ -115,3 +116,8 @@ if(process.argv[2] === "dev") | |||
| 		} | ||||
| 	}); | ||||
| } | ||||
| 
 | ||||
| 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 $ from "../core/lib"; | ||||
| 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.
 | ||||
| let commands: Collection<string, Command>|null = null; | ||||
|  | @ -19,10 +19,14 @@ export default new Event({ | |||
| 		if(message.author.bot) | ||||
| 			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.client.user && message.mentions.has(message.client.user)) | ||||
| 				message.channel.send(`${message.author.toString()}, my prefix on this guild is \`${prefix}\`.`); | ||||
| 			return; | ||||
| 		} | ||||
| 		 | ||||
| 		const [header, ...args] = message.content.substring(prefix.length).split(/ +/); | ||||
| 		 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue