mirror of https://github.com/thaldrin/thaldrin.git
more utils
This commit is contained in:
parent
91fd17606e
commit
21656e3a5c
|
@ -0,0 +1,20 @@
|
||||||
|
import modulus from "./modulus";
|
||||||
|
import config from "./config";
|
||||||
|
|
||||||
|
export default async function prefix(id: string, message: string) {
|
||||||
|
let server = await modulus.server(id)
|
||||||
|
// @ts-ignore
|
||||||
|
let prefixes: string[] = [...config.prefixes, ...server.prefix]
|
||||||
|
let prefix: string
|
||||||
|
let exists: boolean
|
||||||
|
for (const p in prefixes) {
|
||||||
|
if (message.startsWith(prefixes[p])) {
|
||||||
|
prefix = p
|
||||||
|
exists = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!exists) return { success: false }
|
||||||
|
const args = message.slice(prefixes[prefix].length).trim().split(/ +/g)
|
||||||
|
const command = args.shift().toLowerCase()
|
||||||
|
return { success: true, command, args, prefix }
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export default function replace(to_replace: any, replace_with: string, full_string: string) {
|
||||||
|
|
||||||
|
return full_string.replace(to_replace, replace_with)
|
||||||
|
}
|
Loading…
Reference in New Issue