-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #491 from Faf4a/v6
[bug fix] some stuff
- Loading branch information
Showing
8 changed files
with
123 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = async d => { | ||
const data = d.util.aoiFunc(d); | ||
if (data.err) return d.error(data.err); | ||
|
||
const [resolve] = data.inside.splits; | ||
|
||
const guild = d.client.guilds.cache.get(resolve) || d.client.guilds.cache.find(g => g.name.toLowerCase() === resolve.toLowerCase()); | ||
|
||
data.result = guild ? guild.id : undefined; | ||
|
||
return { | ||
code: d.util.setCode(data) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,53 @@ | ||
module.exports = async (d) => { | ||
const {code} = d.command; | ||
const inside = d.unpack(); | ||
const err = d.inside(inside); | ||
if (err) return d.error(err); | ||
|
||
let [amt, filter = "everyone", returnCount = "false", channelID = d.channel.id] = | ||
inside.splits; | ||
|
||
amt = Number(amt); | ||
if (isNaN(amt)) | ||
return d.aoiError.fnError( | ||
d, | ||
"custom", | ||
{inside}, | ||
"Invalid Amout Provided In", | ||
); | ||
|
||
const channel = await d.util.getChannel(d, channelID); | ||
if (!channel) return d.aoiError.fnError(d, "channel", {inside}); | ||
|
||
let messages = await channel.messages | ||
.fetch({limit: 100, cache: false}) | ||
.catch((err) => { | ||
d.aoiError.fnError( | ||
d, | ||
"custom", | ||
{}, | ||
"Failed To Fetch Messages With Reason: " + err, | ||
); | ||
}); | ||
|
||
messages = [...messages.filter((x) => | ||
filter === "everyone" | ||
? true | ||
: filter === "unPins" | ||
? !x.pinned | ||
: filter === "bot" | ||
? x.author?.bot | ||
: x.author?.id === filter, | ||
).values()].slice(0, amt); | ||
|
||
let result = await channel.bulkDelete(messages, true).catch((err) => { | ||
d.aoiError.fnError( | ||
d, | ||
"custom", | ||
{}, | ||
"Failed To Delete Message With Reason: " + err, | ||
); | ||
const data = d.util.aoiFunc(d); | ||
const { code } = d.command; | ||
if (data.err) return d.error(data.err); | ||
|
||
let [channelID = d.channel.id, amount, filters = "everyone", returnCount = false ] = data.inside.splits; | ||
|
||
if (isNaN(amount)) | ||
return d.aoiError.fnError(d, "custom", { inside: data.inside }, "Amount Provided In" ); | ||
amount = +amount + 1; | ||
|
||
const channel = await d.util.getChannel(d, channelID); | ||
if (!channel) | ||
return d.aoiError.fnError(d, "channel", { inside: data.inside }); | ||
|
||
let messages = await channel.messages | ||
.fetch({ limit: 100, cache: false }) | ||
.catch((err) => { | ||
d.aoiError.fnError(d, "custom", {}, "Failed To Fetch Messages With Reason: " + err); | ||
}); | ||
result = returnCount === "true" ? result.size : undefined; | ||
|
||
return { | ||
code: d.util.setCode({function: d.func, code, inside, result}), | ||
}; | ||
}; | ||
filters = filters.toLowerCase().split(","); | ||
|
||
messages = [...messages.values()] | ||
.filter((x) => { | ||
if (filters.includes("everyone")) return true; | ||
if (filters.includes("notpinned") && x.pinned) return false; | ||
if (filters.includes("bots") && x.author?.bot) return true; | ||
if ( | ||
filters.some( | ||
(filter) => | ||
filter.startsWith("user:") && x.author?.id === filter.split(":")[1] | ||
) | ||
) | ||
return true; | ||
return false; | ||
}) | ||
.slice(0, amount); | ||
|
||
if (!messages.length) { | ||
messages = [...messages.values()].slice(0, amount); | ||
} | ||
|
||
let result = await channel.bulkDelete(messages, true).catch((err) => { | ||
d.aoiError.fnError(d, "custom" ,{}, "Failed To Delete Message With Reason: " + err); | ||
}); | ||
|
||
result = returnCount === true ? result.size : undefined; | ||
|
||
return { | ||
code: d.util.setCode({ function: d.func, code, inside: data.inside, result }), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
module.exports = async d => { | ||
const data = d.util.aoiFunc(d); | ||
module.exports = async (d) => { | ||
const data = d.util.aoiFunc(d); | ||
const [text, find] = data.inside.splits; | ||
|
||
const [text = d.args.join(" ")] = data.inside.splits; | ||
data.result = find | ||
? (text.split(find).length - 1) * find.length | ||
: text.length; | ||
|
||
data.result = text.addBrackets().length | ||
|
||
return { | ||
code: d.util.setCode(data) | ||
} | ||
} | ||
return { | ||
code: d.util.setCode(data), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,43 @@ | ||
const chalk = require('chalk'); | ||
|
||
function createCustomBoxedMessage(messages, borderColor = 'yellow', title = null) { | ||
if (!Array.isArray(messages)) { | ||
messages = [messages]; | ||
} | ||
|
||
const maxLength = title | ||
? Math.max(...messages.map(msg => msg.text.length), title.text.length) | ||
: Math.max(...messages.map(msg => msg.text.length)); | ||
|
||
const topBorder = chalk[borderColor](`╭${'─'.repeat(maxLength + 2)}╮`); | ||
const bottomBorder = chalk[borderColor](`╰${'─'.repeat(maxLength + 2)}╯`); | ||
|
||
console.log(topBorder); | ||
|
||
if (title) { | ||
const titlePadding = ' '.repeat((maxLength - title.text.length) / 2); | ||
const titleText = `${chalk[borderColor]('│')} ${titlePadding}${chalk[title.textColor](title.text)}${titlePadding} ${chalk[borderColor]('│')}`; | ||
console.log(titleText); | ||
} | ||
|
||
messages.forEach((message, index) => { | ||
const padding = ' '.repeat(maxLength - message.text.length); | ||
const textColor = message.textColor || 'reset'; // Default to reset color if not specified | ||
const messageText = `${chalk[borderColor]('│')} ${chalk[textColor](message.text)}${padding} ${chalk[borderColor]('│')}`; | ||
console.log(messageText); | ||
}); | ||
|
||
console.log(bottomBorder); | ||
function createCustomBoxedMessage( | ||
messages, | ||
borderColor = "yellow", | ||
title = null | ||
) { | ||
if (!Array.isArray(messages)) { | ||
messages = [messages]; | ||
} | ||
|
||
const maxLength = title | ||
? Math.max(...messages.map((msg) => msg.text.length), title.text.length) | ||
: Math.max(...messages.map((msg) => msg.text.length)); | ||
|
||
const topBorder = chalk[borderColor](`╭${"─".repeat(maxLength + 2)}╮`); | ||
const bottomBorder = chalk[borderColor](`╰${"─".repeat(maxLength + 2)}╯`); | ||
|
||
console.log(topBorder); | ||
|
||
if (title) { | ||
const titlePadding = " ".repeat((maxLength - title.text.length) / 2); | ||
const titleText = `${chalk[borderColor]("│")} ${titlePadding}${chalk[ | ||
title.textColor | ||
](title.text)}${titlePadding} ${chalk[borderColor]("│")}`; | ||
console.log(titleText); | ||
} | ||
|
||
messages.forEach((message, index) => { | ||
const paddingLength = (maxLength - message.text.length) / 2; | ||
const leftPadding = " ".repeat(Math.floor(paddingLength)); | ||
const rightPadding = " ".repeat(Math.ceil(paddingLength)); | ||
const textColor = message.textColor || "reset"; | ||
const messageText = `${chalk[borderColor]("│")} ${leftPadding}${chalk[ | ||
textColor | ||
](message.text)}${rightPadding} ${chalk[borderColor]("│")}`; | ||
console.log(messageText); | ||
}); | ||
|
||
console.log(bottomBorder); | ||
} | ||
|
||
module.exports = createCustomBoxedMessage; |