updated settings commands

Co-authored-by: PineappleFan <PineaFan@users.noreply.github.com>
Co-authored-by: Grey, Skyler <ST137303@hillsroad.ac.uk>
pull/11/head
TheCodedProf 3 years ago
parent f4facde097
commit a112f61ac6

@ -3,7 +3,6 @@
"@discordjs/rest": "^0.2.0-canary.0",
"@hokify/agenda": "^6.2.12",
"@tsconfig/node18-strictest-esm": "^1.0.0",
"@types/lodash": "^4.14.191",
"@types/node-cron": "^3.0.1",
"@ungap/structured-clone": "^1.0.1",
"agenda": "^4.3.0",
@ -11,7 +10,7 @@
"body-parser": "^1.20.0",
"chalk": "^5.0.0",
"deno": "^0.1.1",
"discord.js": "14.7.1",
"discord.js": "^14.7.1",
"eslint": "^8.21.0",
"express": "^4.18.1",
"form-data": "^4.0.0",
@ -61,6 +60,7 @@
"private": false,
"type": "module",
"devDependencies": {
"@types/lodash": "^4.14.191",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"eslint-config-prettier": "^8.5.0",

@ -39,7 +39,7 @@ const styles: Record<string, {emoji: string}> = {
"tags": {emoji: "PUNISH.NICKNAME.RED"},
"ticket": {emoji: "GUILD.TICKET.CLOSE"},
"user": {emoji: "MEMBER.LEAVE"},
"verify": {emoji: "CONTROL.BLOCKTICK"}
"verify": {emoji: "CONTROL.REDTICK"}
}
const callback = async (interaction: CommandInteraction): Promise<void> => {

@ -435,6 +435,8 @@ const check = (interaction: CommandInteraction) => {
return true;
};
export { command };
export { callback };
export { check };
export { command, callback, check };
export const metadata = {
longDescription: "Shows the moderation history (all previous bans, kicks, warns etc.), and moderator notes for a user.",
premiumOnly: true,
}

@ -199,3 +199,7 @@ const check = async (interaction: CommandInteraction, partial: boolean = false)
};
export { command, callback, check };
export const metadata = {
longDescription: "Removes a member from the server - this will prevent them from rejoining until they are unbanned, and will delete a specified number of days of messages from them.",
premiumOnly: true,
}

@ -197,3 +197,7 @@ const check = (interaction: CommandInteraction, partial: boolean = false) => {
};
export { command, callback, check };
export const metadata = {
longDescription: "Removes a member from the server. They will be able to rejoin if they have an invite link.",
premiumOnly: true,
}

@ -389,3 +389,7 @@ const check = async (interaction: CommandInteraction, partial: boolean = false)
};
export { command, callback, check };
export const metadata = {
longDescription: "Stops a member from being able to send messages or join voice channels for a specified amount of time.",
premiumOnly: true,
}

@ -217,3 +217,7 @@ const check = async (interaction: CommandInteraction, partial: boolean = false)
};
export { command, callback, check };
export const metadata = {
longDescription: "Changes the nickname of a member. This is the name that shows in the member list and on messages.",
premiumOnly: true,
}

@ -407,3 +407,7 @@ const check = (interaction: CommandInteraction, partial: boolean = false) => {
};
export { command, callback, check };
export const metadata = {
longDescription: "Deletes a specified amount of messages from a channel, optionally from a specific user. Without an amount, you can repeatedly choose a number of messages to delete.",
premiumOnly: true,
}

@ -88,3 +88,7 @@ const check = (interaction: CommandInteraction, partial: boolean = false) => {
};
export { command, callback, check };
export const metadata = {
longDescription: "Stops members from being able to send messages without waiting a certain amount of time between messages.",
premiumOnly: true,
}

@ -0,0 +1,8 @@
import { group } from "../../../utils/commandRegistration/slashCommandBuilder.js";
const name = "filters";
const description = "Settings for filters";
const subcommand = await group(name, description, `settings/filters`)
export { name, description, subcommand as command};

@ -9,7 +9,9 @@ import createPageIndicator from "../../utils/createPageIndicator.js";
import { configToDropdown } from "../../actions/roleMenu.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
import lodash from 'lodash';
const isEqual = lodash.isEqual;
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("rolemenu")
@ -37,6 +39,60 @@ const defaultRolePageConfig = {
]
}
const reorderRoleMenuPages = async (interaction: CommandInteraction, m: Message, currentObj: ObjectSchema[]) => {
let reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId("reorder")
.setPlaceholder("Select a page to move...")
.setMinValues(1)
.addOptions(
currentObj.map((o, i) => new StringSelectMenuOptionBuilder()
.setLabel(o.name)
.setValue(i.toString())
)
)
);
let buttonRow = new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId("back")
.setLabel("Back")
.setStyle(ButtonStyle.Secondary)
.setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
)
await interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Role Menu")
.setDescription("Select pages in the order you want them to appear.")
.setStatus("Success")
],
components: [reorderRow, buttonRow]
});
let out: StringSelectMenuInteraction | ButtonInteraction | null;
try {
out = await m.awaitMessageComponent({
filter: (i) => i.channel!.id === interaction.channel!.id,
time: 300000
}) as StringSelectMenuInteraction | ButtonInteraction | null;
} catch (e) {
console.error(e);
out = null;
}
if(!out) return;
if (out.isButton()) return;
if(!out.values) return;
const values = out.values;
const newOrder: ObjectSchema[] = currentObj.map((_, i) => {
const index = values.findIndex(v => v === i.toString());
return currentObj[index];
}) as ObjectSchema[];
return newOrder;
}
const editNameDescription = async (i: ButtonInteraction, interaction: StringSelectMenuInteraction | ButtonInteraction, m: Message, data: {name?: string, description?: string}) => {
let {name, description} = data;
@ -374,6 +430,9 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
page = currentObject.length - 1;
break;
case "reorder":
let reordered = await reorderRoleMenuPages(interaction, m, currentObject);
if(!reordered) break;
currentObject = reordered;
break;
case "save":
client.database.guilds.write(interaction.guild.id, {"roleMenu.options": currentObject});

@ -0,0 +1,26 @@
import type { CommandInteraction, GuildMember, SlashCommandSubcommandBuilder } from "discord.js";
import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("tracks")
.setDescription("Manage the tracks for the server")
const callback = async (interaction: CommandInteraction) => {
}
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
const member = interaction.member as GuildMember;
if (!member.permissions.has("ManageRoles"))
return "You must have the *Manage Server* permission to use this command";
return true;
};
export { command };
export { callback };
export { check };

@ -80,7 +80,7 @@ export async function testLink(link: string): Promise<{ safe: boolean; tags: str
}
export async function saveAttachment(link: string): Promise<string> {
const image = (await (await fetch(link)).buffer()).toString("base64");
const image = (await fetch(link)).arrayBuffer().toString();
const fileName = generateFileName(link.split("/").pop()!.split(".").pop()!);
writeFileSync(fileName, image, "base64");
return fileName;

Loading…
Cancel
Save