forked from Galactic/galactic-bot
- Fix commands relying on MemberWrapper instead of UserWrapper
- Add vckick command
This commit is contained in:
parent
427f07c5bb
commit
45bf4efce4
@ -3,7 +3,7 @@ import DiscordClient from '../../../DiscordClient.js';
|
||||
import { Nickname } from '../../../infractions/index.js';
|
||||
import { CommandError, ModerationCommand } from '../../../interfaces/index.js';
|
||||
import InvokerWrapper from '../../wrappers/InvokerWrapper.js';
|
||||
import UserWrapper from '../../wrappers/UserWrapper.js';
|
||||
import MemberWrapper from '../../wrappers/MemberWrapper.js';
|
||||
|
||||
class DehoistCommand extends ModerationCommand
|
||||
{
|
||||
@ -22,15 +22,15 @@ class DehoistCommand extends ModerationCommand
|
||||
|
||||
}
|
||||
|
||||
async execute (invoker: InvokerWrapper, { users, ...args }: CommandParams)
|
||||
async execute (invoker: InvokerWrapper<true>, { users, ...args }: CommandParams)
|
||||
{
|
||||
|
||||
if (!users)
|
||||
throw new CommandError(invoker, { index: 'MODERATION_MISSING_USERS' });
|
||||
|
||||
const wrappers = await Promise.all(users.asUsers.map(user => this.client.getUserWrapper(user)));
|
||||
const wrappers = await Promise.all(users!.asUsers.map(user => invoker.guild.memberWrapper(user)));
|
||||
return this.client.moderation.handleInfraction(Nickname, invoker, {
|
||||
targets: wrappers.filter(Boolean) as UserWrapper[],
|
||||
targets: wrappers.filter(Boolean) as MemberWrapper[],
|
||||
args,
|
||||
data: {
|
||||
dehoist: true
|
||||
|
@ -3,7 +3,7 @@ import DiscordClient from '../../../DiscordClient.js';
|
||||
import { Kick } from '../../../infractions/index.js';
|
||||
import { ModerationCommand } from '../../../interfaces/index.js';
|
||||
import InvokerWrapper from '../../wrappers/InvokerWrapper.js';
|
||||
import UserWrapper from '../../wrappers/UserWrapper.js';
|
||||
import MemberWrapper from '../../wrappers/MemberWrapper.js';
|
||||
|
||||
class KickCommand extends ModerationCommand
|
||||
{
|
||||
@ -21,11 +21,11 @@ class KickCommand extends ModerationCommand
|
||||
});
|
||||
}
|
||||
|
||||
async execute (invoker: InvokerWrapper, { users, ...args }: CommandParams)
|
||||
async execute (invoker: InvokerWrapper<true>, { users, ...args }: CommandParams)
|
||||
{
|
||||
const wrappers = await Promise.all(users!.asUsers.map(user => this.client.getUserWrapper(user)));
|
||||
const wrappers = await Promise.all(users!.asUsers.map(user => invoker.guild.memberWrapper(user)));
|
||||
return this.client.moderation.handleInfraction(Kick, invoker, {
|
||||
targets: wrappers.filter(Boolean) as UserWrapper[],
|
||||
targets: wrappers.filter(Boolean) as MemberWrapper[],
|
||||
args
|
||||
});
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ import { CommandError, ModerationCommand } from '../../../interfaces/index.js';
|
||||
import DiscordClient from '../../../DiscordClient.js';
|
||||
import InvokerWrapper from '../../wrappers/InvokerWrapper.js';
|
||||
import { CommandOptionType, CommandParams } from '../../../../../@types/Client.js';
|
||||
import UserWrapper from '../../wrappers/UserWrapper.js';
|
||||
import Addrole from '../../../infractions/Addrole.js';
|
||||
import Removerole from '../../../infractions/Removerole.js';
|
||||
import MemberWrapper from '../../wrappers/MemberWrapper.js';
|
||||
|
||||
class AddroleCommand extends ModerationCommand
|
||||
{
|
||||
@ -46,7 +46,7 @@ class AddroleCommand extends ModerationCommand
|
||||
|
||||
}
|
||||
|
||||
async execute (invoker: InvokerWrapper, { users, roles, ...args }: CommandParams)
|
||||
async execute (invoker: InvokerWrapper<true>, { users, roles, ...args }: CommandParams)
|
||||
{
|
||||
|
||||
if (!users)
|
||||
@ -56,9 +56,9 @@ class AddroleCommand extends ModerationCommand
|
||||
|
||||
const Infraction = invoker.subcommand!.name === 'add' ? Addrole : Removerole;
|
||||
|
||||
const wrappers = await Promise.all(users.asUsers.map(user => this.client.getUserWrapper(user)));
|
||||
const wrappers = await Promise.all(users!.asUsers.map(user => invoker.guild.memberWrapper(user)));
|
||||
return this.client.moderation.handleInfraction(Infraction, invoker, {
|
||||
targets: wrappers.filter(Boolean) as UserWrapper[],
|
||||
targets: wrappers.filter(Boolean) as MemberWrapper[],
|
||||
args,
|
||||
data: {
|
||||
roleIds: roles.asRoles.map((r) => r.id),
|
||||
|
@ -3,7 +3,7 @@ import DiscordClient from '../../../DiscordClient.js';
|
||||
import { Unmute } from '../../../infractions/index.js';
|
||||
import { CommandError, ModerationCommand } from '../../../interfaces/index.js';
|
||||
import InvokerWrapper from '../../wrappers/InvokerWrapper.js';
|
||||
import UserWrapper from '../../wrappers/UserWrapper.js';
|
||||
import MemberWrapper from '../../wrappers/MemberWrapper.js';
|
||||
|
||||
class UnmuteCommand extends ModerationCommand
|
||||
{
|
||||
@ -22,7 +22,7 @@ class UnmuteCommand extends ModerationCommand
|
||||
});
|
||||
}
|
||||
|
||||
async execute (invoker: InvokerWrapper, { users, ...args }: CommandParams)
|
||||
async execute (invoker: InvokerWrapper<true>, { users, ...args }: CommandParams)
|
||||
{
|
||||
if (!users)
|
||||
throw new CommandError(invoker, { index: 'MODERATION_MISSING_USERS' });
|
||||
@ -35,9 +35,9 @@ class UnmuteCommand extends ModerationCommand
|
||||
else if (!me!.permissions.has('ManageRoles'))
|
||||
throw new CommandError(invoker, { index: 'INHIBITOR_CLIENTPERMISSIONS_ERROR', formatParams: { command: this.name, missing: 'ManageRoles' } });
|
||||
|
||||
const wrappers = await Promise.all(users.asUsers.map(user => this.client.getUserWrapper(user)));
|
||||
const wrappers = await Promise.all(users!.asUsers.map(user => invoker.guild.memberWrapper(user)));
|
||||
return this.client.moderation.handleInfraction(Unmute, invoker, {
|
||||
targets: wrappers.filter(Boolean) as UserWrapper[],
|
||||
targets: wrappers.filter(Boolean) as MemberWrapper[],
|
||||
args
|
||||
});
|
||||
}
|
||||
|
34
src/client/components/commands/moderation/Vckick.ts
Normal file
34
src/client/components/commands/moderation/Vckick.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { CommandParams } from '../../../../../@types/Client.js';
|
||||
import DiscordClient from '../../../DiscordClient.js';
|
||||
import { VcKick } from '../../../infractions/index.js';
|
||||
import { ModerationCommand } from '../../../interfaces/index.js';
|
||||
import InvokerWrapper from '../../wrappers/InvokerWrapper.js';
|
||||
import MemberWrapper from '../../wrappers/MemberWrapper.js';
|
||||
|
||||
class VcKickCommand extends ModerationCommand
|
||||
{
|
||||
constructor (client: DiscordClient)
|
||||
{
|
||||
super(client, {
|
||||
name: 'vckick',
|
||||
description: 'Kick people from a VC.',
|
||||
moduleName: 'moderation',
|
||||
options: [],
|
||||
guildOnly: true,
|
||||
showUsage: true,
|
||||
memberPermissions: [ 'MoveMembers' ],
|
||||
clientPermissions: [ 'MoveMembers' ],
|
||||
});
|
||||
}
|
||||
|
||||
async execute (invoker: InvokerWrapper<true>, { users, ...args }: CommandParams)
|
||||
{
|
||||
const wrappers = await Promise.all(users!.asUsers.map(user => invoker.guild.memberWrapper(user)));
|
||||
return this.client.moderation.handleInfraction(VcKick, invoker, {
|
||||
targets: wrappers.filter(Boolean) as MemberWrapper[],
|
||||
args
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default VcKickCommand;
|
Loading…
Reference in New Issue
Block a user