diff --git a/src/functions/user/referenceUserId.js b/src/functions/user/referenceUserId.js new file mode 100644 index 000000000..4d4d1de4d --- /dev/null +++ b/src/functions/user/referenceUserId.js @@ -0,0 +1,15 @@ +module.exports = async (d) => { + const data = d.util.aoiFunc(d); + const [messageID = d.message.id] = data.inside.splits; + + const message = messageID ? await d.channel.messages.fetch(messageID) : d.message; + if (!message) return d.aoiError.fnError(d, 'message', { inside: data.inside }); + + const id = message.reference?.messageId; + + data.result = id ? (await d.channel.messages.fetch(id))?.author.id : ''; + + return { + code: d.util.setCode(data), + } + } diff --git a/src/functions/util/stringEndsWith.js b/src/functions/util/stringEndsWith.js index 2b5b9d0a9..9f223e045 100644 --- a/src/functions/util/stringEndsWith.js +++ b/src/functions/util/stringEndsWith.js @@ -2,11 +2,11 @@ module.exports = async d => { const data = d.util.aoiFunc(d); if (data.err) return d.error(data.err); - const [text, check] = data.inside.splits; - - data.result = text.addBrackets().endsWith(check.addBrackets()); + const [text, ...checks] = data.inside.splits; + const result = checks.some(check => text.addBrackets().endsWith(check.addBrackets())); + data.result = result return { - code: d.util.setCode(data) + code: d.util.setCode(data) } -} \ No newline at end of file + } diff --git a/src/functions/util/stringStartsWith.js b/src/functions/util/stringStartsWith.js index 731d43786..ae51b2cc7 100644 --- a/src/functions/util/stringStartsWith.js +++ b/src/functions/util/stringStartsWith.js @@ -2,11 +2,11 @@ module.exports = async d => { const data = d.util.aoiFunc(d); if (data.err) return d.error(data.err); - const [text, check] = data.inside.splits; - - data.result = text.addBrackets().startsWith(check.addBrackets()); + const [text, ...checks] = data.inside.splits; + const result = checks.some(check => text.addBrackets().startsWith(check.addBrackets())); + data.result = result return { - code: d.util.setCode(data) + code: d.util.setCode(data) } -} \ No newline at end of file + } diff --git a/src/index.d.ts b/src/index.d.ts index dfc1d07b8..a1d2cadc7 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -256,6 +256,7 @@ declare module "aoi.js" { constructor(options: ClientOptions); status(d: StatusOption[]): void; + loadCommands(directory: string, debug?: boolean): void; variables(data: object, table?: string): void; }