Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: v22.2.0
node-version: v22.14.0
- name: Install commitlint
run: yarn add commitlint@latest conventional-changelog-conventionalcommits @commitlint/config-conventional
run: npm i commitlint@latest conventional-changelog-conventionalcommits @commitlint/config-conventional
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: npx commitlint --last --verbose
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: v22.2.0
node-version: v22.14.0
- name: Install dependencies
run: npm install --frozen-lockfile
- name: Run linter + prettier
Expand All @@ -56,7 +56,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: v22.2.0
node-version: v22.14.0
- name: Install dependencies
run: npm install --frozen-lockfile
- name: Run tests
Expand Down
6 changes: 3 additions & 3 deletions commands/faq.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
import { SlashCommandBuilder, EmbedBuilder, MessageFlags } from 'discord.js';
import Logger from '../utils/logger.js';
import { apiFetch } from '../utils/apiFetch.js';

Expand Down Expand Up @@ -45,7 +45,7 @@ export const execute = async (interaction) => {
await interaction.reply({
content:
'The question was not found. Please try again later. If this error persists, please report to the staff team.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}
Expand All @@ -62,7 +62,7 @@ export const execute = async (interaction) => {
Logger.error(e);
await interaction.reply({
content: `An error occurred while retrieving the FAQ entry. Please try again later. If this error persists, please report to the staff team.`,
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
}
};
8 changes: 6 additions & 2 deletions commands/ip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { SlashCommandBuilder, PermissionFlagsBits } from 'discord.js';
import {
SlashCommandBuilder,
PermissionFlagsBits,
MessageFlags,
} from 'discord.js';
import fetch from 'node-fetch';

export const data = new SlashCommandBuilder()
Expand All @@ -11,6 +15,6 @@ export const execute = async (interaction) => {
const ip = await response.text();
await interaction.reply({
content: 'Current ip: `' + ip + '`',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
};
8 changes: 6 additions & 2 deletions commands/purge.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
import {
MessageFlags,
PermissionFlagsBits,
SlashCommandBuilder,
} from 'discord.js';
import { confirmAction } from './utils/confirmAction.js';
import { hasPermission } from './utils/hasPermission.js';
import {
Expand Down Expand Up @@ -82,7 +86,7 @@ const previewPurge = async (interaction) => {

await interaction.reply({
embeds: [embed],
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
};

Expand Down
15 changes: 8 additions & 7 deletions commands/reactionRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
SlashCommandBuilder,
PermissionFlagsBits,
EmbedBuilder,
MessageFlags,
} from 'discord.js';
import Logger from '../utils/logger.js';
import Paginate from './utils/paginate.js';
Expand Down Expand Up @@ -90,20 +91,20 @@ const addReactionRole = async (interaction) => {
.join('\n\n');
await interaction.reply({
content: errors,
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}

await interaction.reply({
content: 'Reaction role was created.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
} catch (e) {
Logger.error(e);
await interaction.reply({
content: `An error occurred while creating the reaction role entry. Please try again later. If this error persists, please report to the staff team.`,
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
}
};
Expand All @@ -120,7 +121,7 @@ const listReactionRole = async (interaction) => {
Logger.error(`Could not load reaction roles: ${reactionRoles}`);
await interaction.reply({
content: `An error occurred while fetching the reaction roles. Please try again later. If this error persists, please report to the staff team.`,
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
}

Expand All @@ -147,7 +148,7 @@ const listReactionRole = async (interaction) => {
await interaction.reply({
content:
'An error occoured while fetching the reaction roles. Please try again later. If this error persists, please report to the staff team.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}
Expand Down Expand Up @@ -193,13 +194,13 @@ const removeReactionRole = async (interaction) => {

await interaction.reply({
content: 'The reaction role has been removed.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
} catch (e) {
Logger.error(e);
await interaction.reply({
content: `An error occurred while removing the reaction role. Please try again later. If this error persists, please report to the staff team.`,
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
}
};
5 changes: 3 additions & 2 deletions commands/reportChunkloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
PermissionFlagsBits,
EmbedBuilder,
ButtonStyle,
MessageFlags,
} from 'discord.js';
import { hasPermission } from './utils/hasPermission.js';
import { confirmAction } from './utils/confirmAction.js';
Expand Down Expand Up @@ -150,12 +151,12 @@ export const execute = async (interaction) => {
await interaction.editReply({
content:
'An error occurred while reporting your chunkloader. Please try again later. If this error persists, please report to the staff team.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
}

await interaction.editReply({
content: 'Thank you for reporting your chunkloader.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
};
6 changes: 3 additions & 3 deletions commands/rule.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
import { SlashCommandBuilder, EmbedBuilder, MessageFlags } from 'discord.js';
import Logger from '../utils/logger.js';
import { apiFetch } from '../utils/apiFetch.js';

Expand Down Expand Up @@ -48,7 +48,7 @@ export const execute = async (interaction) => {
await interaction.reply({
content:
'The rule was not found please try again later. If this error persists, please report to the staff team.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}
Expand All @@ -65,7 +65,7 @@ export const execute = async (interaction) => {
Logger.error(e);
await interaction.reply({
content: `An error occurred while retrieving the rule entry. Please try again later. If this error persists, please report to the staff team.`,
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
}
};
31 changes: 29 additions & 2 deletions commands/ticket/add.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
import { SlashCommandBuilder, EmbedBuilder, MessageFlags } from 'discord.js';
import ticketState from '../../states/TicketState.js';
import Logger from '../../utils/logger.js';
import { apiFetch } from '../../utils/apiFetch.js';
import { replyError } from '../../utils/replyError.js';
import { addRole, removeRole } from '../../utils/roles.js';

export const data = new SlashCommandBuilder()
.setName('ticket-add')
Expand All @@ -12,16 +13,20 @@ export const data = new SlashCommandBuilder()
.setName('user')
.setDescription('The user to add to the ticket.')
.setRequired(true)
)
.addBooleanOption((option) =>
option.setName('restrict').setDescription('Restrict the User')
);

export const execute = async (interaction) => {
const user = interaction.options.getUser('user');
const shouldRestrict = interaction.options.getBoolean('restrict') ?? false;
if (
!Object.keys(ticketState.getChannelIds()).includes(interaction.channelId)
) {
await interaction.reply({
content: 'This is not a ticket channel.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}
Expand Down Expand Up @@ -66,6 +71,28 @@ export const execute = async (interaction) => {
.setDescription(`${user} has been added to ${interaction.channel}`),
],
});

if (shouldRestrict) {
let member;
try {
member = await interaction.guild.members.fetch(user.id);
} catch (error) {
Logger.error(`Could not get member for restricting: ${error}`);
return;
}

const addedRole = addRole(member, process.env.RESTRICTED_ROLE_ID);
const removedRole = removeRole(member, process.env.MEMBER_ROLE_ID);

let restictMessage = `Could not restrict ${user}.`;
if (addedRole && removedRole) {
restictMessage = `${user} was restricted.`;
}
await interaction.followUp({
content: restictMessage,
flags: MessageFlags.Ephemeral,
});
}
} catch (error) {
Logger.error(`Could not add user to ticket: ${error}`);
await replyError(
Expand Down
4 changes: 2 additions & 2 deletions commands/ticket/remove.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
import { SlashCommandBuilder, EmbedBuilder, MessageFlags } from 'discord.js';
import ticketState from '../../states/TicketState.js';
import Logger from '../../utils/logger.js';
import { apiFetch } from '../../utils/apiFetch.js';
Expand All @@ -21,7 +21,7 @@ export const execute = async (interaction) => {
) {
await interaction.reply({
content: 'This is not a ticket channel.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}
Expand Down
9 changes: 5 additions & 4 deletions commands/ticket/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
PermissionFlagsBits,
ChannelType,
PermissionsBitField,
MessageFlags,
} from 'discord.js';
import { apiFetch } from '../../utils/apiFetch.js';

Expand All @@ -26,7 +27,7 @@ export const data = new SlashCommandBuilder()

export const execute = async (interaction) => {
await interaction.deferReply({
ephemeral: true,
flags: MessageFlags.Ephemeral,
});

const responseConfig = await apiFetch('/ticket/config', {
Expand All @@ -40,7 +41,7 @@ export const execute = async (interaction) => {
if (ticketConfig.data?.id) {
await interaction.editReply({
content: 'The setup is completed. Please use the helper panel.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}
Expand Down Expand Up @@ -91,7 +92,7 @@ export const execute = async (interaction) => {
await interaction.editReply({
content:
'An error occurred while setting up the ticket system. Please try again later. If this error persists, please report to the staff team.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
category.delete();
transcriptChannel.delete();
Expand All @@ -101,6 +102,6 @@ export const execute = async (interaction) => {

await interaction.editReply({
content: 'tickets setup completed.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
};
14 changes: 7 additions & 7 deletions commands/utils/apply/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EmbedBuilder } from 'discord.js';
import { EmbedBuilder, MessageFlags } from 'discord.js';
import { confirmActionDm } from '../confirmActionDm.js';
import { Logger } from '../../../utils/index.js';
import { applicationStartedDmEmbed, closedDmEmbed } from './embeds.js';
Expand All @@ -13,13 +13,13 @@ import {

export const handleApplication = async (interaction, applicationId) => {
const member = interaction.member;
await interaction.deferReply({ ephemeral: true });
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
const application = await getApplicationById(applicationId);
if (!application) {
await interaction.editReply({
content:
'The application was not found. Please use the autocomplete. If this issue pressists contact the staff team.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}
Expand All @@ -28,7 +28,7 @@ export const handleApplication = async (interaction, applicationId) => {
if (member.roles.cache.has(restrictedRole.role_id)) {
await interaction.editReply({
content: 'You do not have the permission to execute that command.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}
Expand All @@ -38,7 +38,7 @@ export const handleApplication = async (interaction, applicationId) => {
if (!member.roles.cache.has(requiredRole.role_id)) {
await interaction.editReply({
content: 'You do not have the permission to execute that command.',
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}
Expand All @@ -54,14 +54,14 @@ export const handleApplication = async (interaction, applicationId) => {
Logger.error('cannot send direct message: ' + e);
await interaction.editReply({
embeds: [closedDmEmbed],
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}
try {
await interaction.editReply({
embeds: [applicationStartedDmEmbed],
ephemeral: true,
flags: MessageFlags.Ephemeral,
});

const confirmed = await confirmActionDm(
Expand Down
Loading