diff --git a/src/commands/fun.ts b/src/commands/fun.ts index 68d63c1..99834d3 100644 --- a/src/commands/fun.ts +++ b/src/commands/fun.ts @@ -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({ diff --git a/src/core/command.ts b/src/core/command.ts index 3ea9a96..a26e4dc 100644 --- a/src/core/command.ts +++ b/src/core/command.ts @@ -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 diff --git a/src/core/structures.ts b/src/core/structures.ts index 2a98839..4bf75fa 100644 --- a/src/core/structures.ts +++ b/src/core/structures.ts @@ -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 { @@ -114,4 +115,9 @@ if(process.argv[2] === "dev") 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; } \ No newline at end of file diff --git a/src/events/message.ts b/src/events/message.ts index 4771fb4..becc9bd 100644 --- a/src/events/message.ts +++ b/src/events/message.ts @@ -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|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(/ +/);