Added pinging bot for prefix and var string prefix

This commit is contained in:
WatDuhHekBro 2020-08-14 04:43:45 -05:00
parent a86e11ed23
commit 77422538df
4 changed files with 16 additions and 4 deletions

View File

@ -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({

View File

@ -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

View File

@ -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;
}

View File

@ -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(/ +/);