Skip to content

Commit

Permalink
MoreCommands Plugin Update ( exodev ) (Vendicated#119)
Browse files Browse the repository at this point in the history
* Update index.ts

* Added ExoDev

* Update index.ts

* Update index.ts
  • Loading branch information
husxdev authored Jan 11, 2025
1 parent 4220ca2 commit 6e3a8de
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 6 deletions.
186 changes: 180 additions & 6 deletions src/plugins/moreCommands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { ApplicationCommandInputType, findOption, OptionalMessageOption, RequiredMessageOption, sendBotMessage } from "@api/Commands";
import { Devs } from "@utils/constants";
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, OptionalMessageOption, RequiredMessageOption, sendBotMessage } from "@api/Commands";
import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types";


function mock(input: string): string {
let output = "";
for (let i = 0; i < input.length; i++) {
Expand All @@ -31,8 +30,8 @@ function mock(input: string): string {

export default definePlugin({
name: "MoreCommands",
description: "echo, lenny, mock",
authors: [Devs.Arjix, Devs.echo, Devs.Samu],
description: "Echo, Lenny, Mock, and More",
authors: [Devs.Arjix, Devs.echo, Devs.Samu, EquicordDevs.ExoDev],
commands: [
{
name: "echo",
Expand All @@ -41,7 +40,6 @@ export default definePlugin({
inputType: ApplicationCommandInputType.BOT,
execute: (opts, ctx) => {
const content = findOption(opts, "message", "");

sendBotMessage(ctx.channel.id, { content });
},
},
Expand All @@ -61,5 +59,181 @@ export default definePlugin({
content: mock(findOption(opts, "message", ""))
}),
},
{
name: "reverse",
description: "Reverses the input message",
options: [RequiredMessageOption],
execute: opts => ({
content: findOption(opts, "message", "").split("").reverse().join("")
}),
},
{
name: "uppercase",
description: "Converts the message to uppercase",
options: [RequiredMessageOption],
execute: opts => ({
content: findOption(opts, "message", "").toUpperCase()
}),
},
{
name: "lowercase",
description: "Converts the message to lowercase",
options: [RequiredMessageOption],
execute: opts => ({
content: findOption(opts, "message", "").toLowerCase()
}),
},
{
name: "wordcount",
description: "Counts the number of words in a message",
options: [RequiredMessageOption],
inputType: ApplicationCommandInputType.BOT,
execute: (opts, ctx) => {
const message = findOption(opts, "message", "");
const wordCount = message.trim().split(/\s+/).length;
sendBotMessage(ctx.channel.id, {
content: `The message contains ${wordCount} words.`
});
},
},
{
name: "servertime",
description: "Displays the current server time",
options: [],
execute: () => {
const currentTime = new Date().toLocaleString();
return {
content: `The current server time is: ${currentTime}`
};
},
},
{
name: "ping",
description: "Pings the bot to check if it's responding",
options: [],
inputType: ApplicationCommandInputType.BOT,
execute: (opts, ctx) => {
sendBotMessage(ctx.channel.id, {
content: "Pong!"
});
},
},
{
name: "rolldice",
description: "Roll a die with the specified number of sides",
options: [RequiredMessageOption],
execute: opts => {
const sides = parseInt(findOption(opts, "message", "6"));
const roll = Math.floor(Math.random() * sides) + 1;
return {
content: `You rolled a ${roll}!`
};
},
},
{
name: "flipcoin",
description: "Flips a coin and returns heads or tails",
options: [],
execute: () => {
const flip = Math.random() < 0.5 ? "Heads" : "Tails";
return {
content: `The coin landed on: ${flip}`
};
},
},
{
name: "ask",
description: "Ask a yes/no question and get an answer",
options: [RequiredMessageOption],
execute: opts => {
const question = findOption(opts, "message", "");
const responses = [
"Yes", "No", "Maybe", "Ask again later", "Definitely not", "It is certain"
];
const response = responses[Math.floor(Math.random() * responses.length)];
return {
content: `${question} - ${response}`
};
},
},
{
name: "randomnumber",
description: "Generates a random number between two values",
options: [
{
name: "min",
description: "Minimum value",
type: ApplicationCommandOptionType.INTEGER,
required: true
},
{
name: "max",
description: "Maximum value",
type: ApplicationCommandOptionType.INTEGER,
required: true
}
],
execute: opts => {
const min = parseInt(findOption(opts, "min", "0"));
const max = parseInt(findOption(opts, "max", "100"));
const number = Math.floor(Math.random() * (max - min + 1)) + min;
return {
content: `Random number between ${min} and ${max}: ${number}`
};
}
},
{
name: "countdown",
description: "Starts a countdown from a specified number",
options: [
{
name: "number",
description: "Number to countdown from (max 10)",
type: ApplicationCommandOptionType.INTEGER,
required: true
}
],
inputType: ApplicationCommandInputType.BOT,
execute: async (opts, ctx) => {
const number = Math.min(parseInt(findOption(opts, "number", "5")), 10);

if (isNaN(number) || number < 1) {
sendBotMessage(ctx.channel.id, {
content: "Please provide a valid number between 1 and 10!"
});
return;
}

sendBotMessage(ctx.channel.id, {
content: `Starting countdown from ${number}...`
});

for (let i = number; i >= 0; i--) {
await new Promise(resolve => setTimeout(resolve, 1000));
sendBotMessage(ctx.channel.id, {
content: i === 0 ? "🎉 Go! 🎉" : `${i}...`
});
}
},
},
{
name: "choose",
description: "Randomly chooses from provided options",
options: [
{
name: "choices",
description: "Comma-separated list of choices",
type: ApplicationCommandOptionType.STRING,
required: true
}
],
execute: opts => {
const choices = findOption(opts, "choices", "").split(",").map(c => c.trim());
const choice = choices[Math.floor(Math.random() * choices.length)];
return {
content: `I choose: ${choice}`
};
}
}
]
});
4 changes: 4 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,10 @@ export const EquicordDevs = Object.freeze({
vappstar: {
name: "vappstar",
id: 747192967311261748n
},
ExoDev: {
name: "ExoDev",
id: 1325655837003223137n
}
} satisfies Record<string, Dev>);

Expand Down

0 comments on commit 6e3a8de

Please sign in to comment.