Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
.env
dist
src/database/qbotdata.db
src/resources/commands.json
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"axios": "^0.24.0",
"bloxy": "5.8.0",
"discord.js": "14.11.0",
"got": "^11.8.2",
"dotenv": "^10.0.0",
"express": "^4.17.2",
"figlet": "^1.5.2",
Expand Down
2 changes: 1 addition & 1 deletion src/arguments/handleRobloxUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AutocompleteInteraction, APIApplicationCommandOptionChoice } from 'discord.js';
import { getLinkedRobloxUser } from '../handlers/accountLinks';
import { robloxClient, robloxGroup } from '../main';
import { robloxClient } from '../main';

const handleRobloxUser = async (interaction: AutocompleteInteraction, option: APIApplicationCommandOptionChoice) => {
if(!option.value) return;
Expand Down
18 changes: 18 additions & 0 deletions src/arguments/handleSecondaryGroup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { AutocompleteInteraction, APIApplicationCommandOptionChoice } from 'discord.js';
import { config } from '../config';

const handleSecondaryGroup = async (interaction: AutocompleteInteraction, option: APIApplicationCommandOptionChoice) => {
let options = config.secondaryGroups.map((group) => ({
name: group.name,
value: group.name,
}));

if(option.value) {
options = options.filter((o) => o.name.toLowerCase().includes((option.value as string).toLowerCase()));
}


await interaction.respond(options.slice(0, 25));
}

export { handleSecondaryGroup };
26 changes: 20 additions & 6 deletions src/commands/admin/exile.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { discordClient, robloxClient, robloxGroup } from '../../main';
import { discordClient, robloxClient, robloxGroup as defaultRobloxGroup } from '../../main';
import { CommandContext } from '../../structures/addons/CommandAddons';
import { Command } from '../../structures/Command';
import {
getInvalidRobloxUserEmbed,
getRobloxUserIsNotMemberEmbed,
getSuccessfulExileEmbed,
getUnexpectedErrorEmbed,
getNoRankBelowEmbed,
getRoleNotFoundEmbed,
getVerificationChecksFailedEmbed,
getUserSuspendedEmbed,
getInvalidRobloxGroupEmbed,
} from '../../handlers/locale';
import { config } from '../../config';
import { User, PartialUser, GroupMember } from 'bloxy/dist/structures';
import { User, PartialUser, GroupMember, Group } from 'bloxy/dist/structures';
import { checkActionEligibility } from '../../handlers/verificationChecks';
import { logAction } from '../../handlers/handleLogging';
import { getLinkedRobloxUser } from '../../handlers/accountLinks';
Expand All @@ -39,6 +38,14 @@ class ExileCommand extends Command {
required: false,
type: 'String',
},
{
trigger: 'group',
description: 'Which secondary group would you like to run this action in, if any?',
isLegacyFlag: true,
autocomplete: true,
required: false,
type: 'SecondaryGroup',
}
],
permissions: [
{
Expand All @@ -51,6 +58,13 @@ class ExileCommand extends Command {
}

async run(ctx: CommandContext) {
let robloxGroup: Group = defaultRobloxGroup;
if(ctx.args['group']) {
const secondaryGroup = config.secondaryGroups.find((group) => group.name.toLowerCase() === ctx.args['group'].toLowerCase());
if(!secondaryGroup) return ctx.reply({ embeds: [ getInvalidRobloxGroupEmbed() ]});
robloxGroup = await robloxClient.getGroup(secondaryGroup.id);
}

let robloxUser: User | PartialUser;
try {
robloxUser = await robloxClient.getUser(ctx.args['roblox-user'] as number);
Expand Down Expand Up @@ -80,8 +94,8 @@ class ExileCommand extends Command {
return ctx.reply({ embeds: [ getRobloxUserIsNotMemberEmbed() ]});
}

if(config.verificationChecks) {
const actionEligibility = await checkActionEligibility(ctx.user.id, ctx.guild.id, robloxMember, robloxMember.role.rank);
if(config.verificationChecks.enabled) {
const actionEligibility = await checkActionEligibility(robloxGroup, ctx.user.id, ctx.member.roles.cache.map((r) => r.id), ctx.guild.id, robloxMember, robloxMember.role.rank);
if(!actionEligibility) return ctx.reply({ embeds: [ getVerificationChecksFailedEmbed() ] });
}

Expand Down
6 changes: 2 additions & 4 deletions src/commands/admin/groupban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import { provider } from '../../database';
import { logAction } from '../../handlers/handleLogging';
import {
getInvalidRobloxUserEmbed,
getRobloxUserIsNotMemberEmbed,
getVerificationChecksFailedEmbed,
getUnexpectedErrorEmbed,
getSuccessfulGroupBanEmbed,
getNoDatabaseEmbed,
getUserBannedEmbed
} from '../../handlers/locale';
import { config } from '../../config';
Expand Down Expand Up @@ -77,8 +75,8 @@ class GroupBanCommand extends Command {
if(!robloxMember) throw new Error();
} catch (err) {};

if(config.verificationChecks && robloxMember) {
const actionEligibility = await checkActionEligibility(ctx.user.id, ctx.guild.id, robloxMember, robloxMember.role.rank);
if(config.verificationChecks.enabled && robloxMember) {
const actionEligibility = await checkActionEligibility(robloxGroup, ctx.user.id, ctx.member.roles.cache.map((r) => r.id), ctx.guild.id, robloxMember, robloxMember.role.rank);
if(!actionEligibility) return ctx.reply({ embeds: [ getVerificationChecksFailedEmbed() ] });
}

Expand Down
1 change: 0 additions & 1 deletion src/commands/admin/ungroupban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
getInvalidRobloxUserEmbed,
getUnexpectedErrorEmbed,
getSuccessfulGroupUnbanEmbed,
getNoDatabaseEmbed,
getUserNotBannedEmbed
} from '../../handlers/locale';
import { config } from '../../config';
Expand Down
3 changes: 0 additions & 3 deletions src/commands/information/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import { getLinkedRobloxUser } from '../../handlers/accountLinks';
import { config } from '../../config';
import {
getInvalidRobloxUserEmbed,
getNoDatabaseEmbed,
getPartialUserInfoEmbed,
getRobloxUserIsNotMemberEmbed,
getUnexpectedErrorEmbed,
getUserInfoEmbed,
} from '../../handlers/locale';
import { provider } from '../../database';
Expand Down
22 changes: 19 additions & 3 deletions src/commands/join-requests/acceptjoin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { discordClient, robloxClient, robloxGroup } from '../../main';
import { discordClient, robloxClient, robloxGroup as defaultRobloxGroup } from '../../main';
import { CommandContext } from '../../structures/addons/CommandAddons';
import { Command } from '../../structures/Command';
import {
getInvalidRobloxUserEmbed,
getUnexpectedErrorEmbed,
getSuccessfulAcceptJoinRequestEmbed,
getNoJoinRequestEmbed,
getInvalidRobloxGroupEmbed,
} from '../../handlers/locale';
import { config } from '../../config';
import { User, PartialUser, GroupMember } from 'bloxy/dist/structures';
import { User, PartialUser, Group } from 'bloxy/dist/structures';
import { logAction } from '../../handlers/handleLogging';
import { getLinkedRobloxUser } from '../../handlers/accountLinks';

Expand All @@ -33,6 +34,14 @@ class AcceptJoinCommand extends Command {
required: false,
type: 'String',
},
{
trigger: 'group',
description: 'Which secondary group would you like to run this action in, if any?',
isLegacyFlag: true,
autocomplete: true,
required: false,
type: 'SecondaryGroup',
}
],
permissions: [
{
Expand All @@ -45,6 +54,13 @@ class AcceptJoinCommand extends Command {
}

async run(ctx: CommandContext) {
let robloxGroup: Group = defaultRobloxGroup;
if(ctx.args['group']) {
const secondaryGroup = config.secondaryGroups.find((group) => group.name.toLowerCase() === ctx.args['group'].toLowerCase());
if(!secondaryGroup) return ctx.reply({ embeds: [ getInvalidRobloxGroupEmbed() ]});
robloxGroup = await robloxClient.getGroup(secondaryGroup.id);
}

let robloxUser: User | PartialUser;
try {
robloxUser = await robloxClient.getUser(ctx.args['roblox-user'] as number);
Expand All @@ -66,7 +82,7 @@ class AcceptJoinCommand extends Command {
}
}

const joinRequest = await robloxUser.getJoinRequestInGroup(config.groupId);
const joinRequest = await robloxUser.getJoinRequestInGroup(robloxGroup.id);
if(!joinRequest) return ctx.reply({ embeds: [ getNoJoinRequestEmbed() ] });

try {
Expand Down
22 changes: 19 additions & 3 deletions src/commands/join-requests/denyjoin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { discordClient, robloxClient, robloxGroup } from '../../main';
import { discordClient, robloxClient, robloxGroup as defaultRobloxGroup } from '../../main';
import { CommandContext } from '../../structures/addons/CommandAddons';
import { Command } from '../../structures/Command';
import {
getInvalidRobloxUserEmbed,
getUnexpectedErrorEmbed,
getSuccessfulDenyJoinRequestEmbed,
getNoJoinRequestEmbed,
getInvalidRobloxGroupEmbed
} from '../../handlers/locale';
import { config } from '../../config';
import { User, PartialUser } from 'bloxy/dist/structures';
import { User, PartialUser, Group } from 'bloxy/dist/structures';
import { logAction } from '../../handlers/handleLogging';
import { getLinkedRobloxUser } from '../../handlers/accountLinks';

Expand All @@ -33,6 +34,14 @@ class DenyJoinCommand extends Command {
required: false,
type: 'String',
},
{
trigger: 'group',
description: 'Which secondary group would you like to run this action in, if any?',
isLegacyFlag: true,
autocomplete: true,
required: false,
type: 'SecondaryGroup',
}
],
permissions: [
{
Expand All @@ -45,6 +54,13 @@ class DenyJoinCommand extends Command {
}

async run(ctx: CommandContext) {
let robloxGroup: Group = defaultRobloxGroup;
if(ctx.args['group']) {
const secondaryGroup = config.secondaryGroups.find((group) => group.name.toLowerCase() === ctx.args['group'].toLowerCase());
if(!secondaryGroup) return ctx.reply({ embeds: [ getInvalidRobloxGroupEmbed() ]});
robloxGroup = await robloxClient.getGroup(secondaryGroup.id);
}

let robloxUser: User | PartialUser;
try {
robloxUser = await robloxClient.getUser(ctx.args['roblox-user'] as number);
Expand All @@ -66,7 +82,7 @@ class DenyJoinCommand extends Command {
}
}

const joinRequest = await robloxUser.getJoinRequestInGroup(config.groupId);
const joinRequest = await robloxUser.getJoinRequestInGroup(robloxGroup.id);
if(!joinRequest) return ctx.reply({ embeds: [ getNoJoinRequestEmbed() ] });

try {
Expand Down
22 changes: 20 additions & 2 deletions src/commands/join-requests/joinrequests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { robloxGroup } from '../../main';
import { robloxGroup as defaultRobloxGroup, robloxClient } from '../../main';
import { CommandContext } from '../../structures/addons/CommandAddons';
import { Command } from '../../structures/Command';
import { getJoinRequestsEmbed } from '../../handlers/locale';
import { getJoinRequestsEmbed, getInvalidRobloxGroupEmbed } from '../../handlers/locale';
import { config } from '../../config';
import { Group } from 'bloxy/dist/structures';

class JoinRequestsCommand extends Command {
constructor() {
Expand All @@ -11,6 +12,16 @@ class JoinRequestsCommand extends Command {
description: 'Gets a list of pending join requests.',
type: 'ChatInput',
module: 'join-requests',
args: [
{
trigger: 'group',
description: 'Which secondary group would you like to run this action in, if any?',
isLegacyFlag: true,
autocomplete: true,
required: false,
type: 'SecondaryGroup',
}
],
permissions: [
{
type: 'role',
Expand All @@ -22,6 +33,13 @@ class JoinRequestsCommand extends Command {
}

async run(ctx: CommandContext) {
let robloxGroup: Group = defaultRobloxGroup;
if(ctx.args['group']) {
const secondaryGroup = config.secondaryGroups.find((group) => group.name.toLowerCase() === ctx.args['group'].toLowerCase());
if(!secondaryGroup) return ctx.reply({ embeds: [ getInvalidRobloxGroupEmbed() ]});
robloxGroup = await robloxClient.getGroup(secondaryGroup.id);
}

const joinRequests = await robloxGroup.getJoinRequests({});
return await ctx.reply({ embeds: [ getJoinRequestsEmbed(joinRequests.data) ] });
}
Expand Down
24 changes: 20 additions & 4 deletions src/commands/ranking/demote.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { discordClient, robloxClient, robloxGroup } from '../../main';
import { discordClient, robloxClient, robloxGroup as defaultRobloxGroup } from '../../main';
import { CommandContext } from '../../structures/addons/CommandAddons';
import { Command } from '../../structures/Command';
import {
Expand All @@ -10,9 +10,10 @@ import {
getRoleNotFoundEmbed,
getVerificationChecksFailedEmbed,
getUserSuspendedEmbed,
getInvalidRobloxGroupEmbed,
} from '../../handlers/locale';
import { config } from '../../config';
import { User, PartialUser, GroupMember } from 'bloxy/dist/structures';
import { User, PartialUser, GroupMember, Group } from 'bloxy/dist/structures';
import { checkActionEligibility } from '../../handlers/verificationChecks';
import { logAction } from '../../handlers/handleLogging';
import { getLinkedRobloxUser } from '../../handlers/accountLinks';
Expand All @@ -39,6 +40,14 @@ class PromoteCommand extends Command {
required: false,
type: 'String',
},
{
trigger: 'group',
description: 'Which secondary group would you like to run this action in, if any?',
isLegacyFlag: true,
autocomplete: true,
required: false,
type: 'SecondaryGroup',
}
],
permissions: [
{
Expand All @@ -51,6 +60,13 @@ class PromoteCommand extends Command {
}

async run(ctx: CommandContext) {
let robloxGroup: Group = defaultRobloxGroup;
if(ctx.args['group']) {
const secondaryGroup = config.secondaryGroups.find((group) => group.name.toLowerCase() === ctx.args['group'].toLowerCase());
if(!secondaryGroup) return ctx.reply({ embeds: [ getInvalidRobloxGroupEmbed() ]});
robloxGroup = await robloxClient.getGroup(secondaryGroup.id);
}

let robloxUser: User | PartialUser;
try {
robloxUser = await robloxClient.getUser(ctx.args['roblox-user'] as number);
Expand Down Expand Up @@ -86,8 +102,8 @@ class PromoteCommand extends Command {
if(!role.rank || role.rank === 0) return ctx.reply({ embeds: [ getNoRankBelowEmbed() ]});
if(role.rank > config.maximumRank || robloxMember.role.rank > config.maximumRank) return ctx.reply({ embeds: [ getRoleNotFoundEmbed() ] });

if(config.verificationChecks) {
const actionEligibility = await checkActionEligibility(ctx.user.id, ctx.guild.id, robloxMember, role.rank);
if(config.verificationChecks.enabled) {
const actionEligibility = await checkActionEligibility(robloxGroup, ctx.user.id, ctx.member.roles.cache.map((r) => r.id), ctx.guild.id, robloxMember, role.rank);
if(!actionEligibility) return ctx.reply({ embeds: [ getVerificationChecksFailedEmbed() ] });
}

Expand Down
Loading