-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrated to new discord command structure
- Loading branch information
kk
committed
Nov 25, 2023
1 parent
247ad1f
commit 97a65ef
Showing
8 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { CommandBase, CommandExecution } from "../../util/SlashCommandHandler"; | ||
import { Client, PermissionsBitField, SlashCommandBuilder } from "discord.js"; | ||
import { MinecraftBot } from "../../index"; | ||
|
||
export default class GuildMuteMember extends CommandBase { | ||
constructor(discordClient: Client<true>, botInstance: MinecraftBot) { | ||
super({ | ||
discordClient, | ||
botInstance, | ||
commandBuilder: new SlashCommandBuilder() | ||
.setName("accept") | ||
.setDescription("Accepts a member into the guild") | ||
.addStringOption((command) => command.setName("player_name").setDescription("The name of the player you'd like to accept.").setRequired(true)) | ||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator), | ||
}); | ||
} | ||
|
||
async execute({ interaction, discordCommandMap }: CommandExecution): Promise<void> { | ||
if (await this.hasPermissionToExecute({ interaction, discordCommandMap })) { | ||
this.getBotInstance() | ||
.getMineflayerInstance() | ||
.chat(`/g accept ${interaction.options.get("player_name")?.value}`); | ||
await interaction.editReply("Command has been executed!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { CommandBase, CommandExecution } from "../../util/SlashCommandHandler"; | ||
import { Client, PermissionsBitField, SlashCommandBuilder } from "discord.js"; | ||
import { MinecraftBot } from "../../index"; | ||
|
||
export default class GuildDemoteMember extends CommandBase { | ||
constructor(discordClient: Client<true>, botInstance: MinecraftBot) { | ||
super({ | ||
discordClient, | ||
botInstance, | ||
commandBuilder: new SlashCommandBuilder() | ||
.setName("demote") | ||
.setDescription("Demotes a member in the guild") | ||
.addStringOption((command) => command.setName("player_name").setDescription("The name of the player you'd like to demote.").setRequired(true)) | ||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator), | ||
}); | ||
} | ||
|
||
async execute({ interaction, discordCommandMap }: CommandExecution): Promise<void> { | ||
if (await this.hasPermissionToExecute({ interaction, discordCommandMap })) { | ||
this.getBotInstance() | ||
.getMineflayerInstance() | ||
.chat(`/g demote ${interaction.options.get("player_name")?.value}`); | ||
await interaction.editReply("Command has been executed!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CommandBase, CommandExecution } from "../../util/SlashCommandHandler"; | ||
import { Client, PermissionsBitField, SlashCommandBuilder } from "discord.js"; | ||
import { MinecraftBot } from "../../index"; | ||
|
||
export default class GuildKickPlayer extends CommandBase { | ||
constructor(discordClient: Client<true>, botInstance: MinecraftBot) { | ||
super({ | ||
discordClient, | ||
botInstance, | ||
commandBuilder: new SlashCommandBuilder() | ||
.setName("kick") | ||
.setDescription("Kicks a member from the guild") | ||
.addStringOption((options) => options.setName("player_name").setDescription("The name of the player you'd like to kick.").setRequired(true)) | ||
.addStringOption((options) => options.setName("reason").setDescription("Reason to kick the player").setRequired(true)) | ||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator), | ||
}); | ||
} | ||
|
||
async execute({ interaction, discordCommandMap }: CommandExecution): Promise<void> { | ||
if (await this.hasPermissionToExecute({ interaction, discordCommandMap })) { | ||
this.getBotInstance() | ||
.getMineflayerInstance() | ||
.chat(`/g kick ${interaction.options.get("player_name")?.value} ${interaction.options.get("reason")?.value}`); | ||
await interaction.editReply("Command has been executed!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { CommandBase, CommandExecution } from "../../util/SlashCommandHandler"; | ||
import { Client, PermissionsBitField, SlashCommandBuilder } from "discord.js"; | ||
import { MinecraftBot } from "../../index"; | ||
|
||
export default class GuildMuteMember extends CommandBase { | ||
constructor(discordClient: Client<true>, botInstance: MinecraftBot) { | ||
super({ | ||
discordClient, | ||
botInstance, | ||
commandBuilder: new SlashCommandBuilder() | ||
.setName("invite") | ||
.setDescription("Invites a member to the guild") | ||
.addStringOption((command) => command.setName("player_name").setDescription("The name of the player you'd like to invite.").setRequired(true)) | ||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator), | ||
}); | ||
} | ||
|
||
async execute({ interaction, discordCommandMap }: CommandExecution): Promise<void> { | ||
if (await this.hasPermissionToExecute({ interaction, discordCommandMap })) { | ||
this.getBotInstance() | ||
.getMineflayerInstance() | ||
.chat(`/g invite ${interaction.options.get("player_name")?.value}`); | ||
await interaction.editReply("Command has been executed!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CommandBase, CommandExecution } from "../../util/SlashCommandHandler"; | ||
import { Client, PermissionsBitField, SlashCommandBuilder } from "discord.js"; | ||
import { MinecraftBot } from "../../index"; | ||
|
||
export default class GuildMuteMember extends CommandBase { | ||
constructor(discordClient: Client<true>, botInstance: MinecraftBot) { | ||
super({ | ||
discordClient, | ||
botInstance, | ||
commandBuilder: new SlashCommandBuilder() | ||
.setName("mute") | ||
.setDescription("Mutes a member in the guild") | ||
.addStringOption((command) => command.setName("player_name").setDescription("The name of the player you'd like to mute.").setRequired(true)) | ||
.addStringOption((options) => options.setName("time_period").setDescription("Time period to mute").setRequired(true)) | ||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator), | ||
}); | ||
} | ||
|
||
async execute({ interaction, discordCommandMap }: CommandExecution): Promise<void> { | ||
if (await this.hasPermissionToExecute({ interaction, discordCommandMap })) { | ||
this.getBotInstance() | ||
.getMineflayerInstance() | ||
.chat(`/g mute ${interaction.options.get("player_name")?.value} ${interaction.options.get("time_period")?.value}`); | ||
await interaction.editReply("Command has been executed!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { CommandBase, CommandExecution } from "../../util/SlashCommandHandler"; | ||
import { Client, PermissionsBitField, SlashCommandBuilder } from "discord.js"; | ||
import { MinecraftBot } from "../../index"; | ||
|
||
export default class GuildPromoteMember extends CommandBase { | ||
constructor(discordClient: Client<true>, botInstance: MinecraftBot) { | ||
super({ | ||
discordClient, | ||
botInstance, | ||
commandBuilder: new SlashCommandBuilder() | ||
.setName("promote") | ||
.setDescription("Promotes a member in the guild") | ||
.addStringOption((command) => command.setName("player_name").setDescription("The name of the player you'd like to promote.").setRequired(true)) | ||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator), | ||
}); | ||
} | ||
|
||
async execute({ interaction, discordCommandMap }: CommandExecution): Promise<void> { | ||
if (await this.hasPermissionToExecute({ interaction, discordCommandMap })) { | ||
this.getBotInstance() | ||
.getMineflayerInstance() | ||
.chat(`/g promote ${interaction.options.get("player_name")?.value}`); | ||
await interaction.editReply("Command has been executed!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { CommandBase, CommandExecution } from "../../util/SlashCommandHandler"; | ||
import { Client, PermissionsBitField, SlashCommandBuilder } from "discord.js"; | ||
import { MinecraftBot } from "../../index"; | ||
|
||
export default class GuildUnmuteMember extends CommandBase { | ||
constructor(discordClient: Client<true>, botInstance: MinecraftBot) { | ||
super({ | ||
discordClient, | ||
botInstance, | ||
commandBuilder: new SlashCommandBuilder() | ||
.setName("unmute") | ||
.setDescription("Unmutes a member in the guild") | ||
.addStringOption((command) => command.setName("player_name").setDescription("The name of the player you'd like to unmute.").setRequired(true)) | ||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator), | ||
}); | ||
} | ||
|
||
async execute({ interaction, discordCommandMap }: CommandExecution): Promise<void> { | ||
if (await this.hasPermissionToExecute({ interaction, discordCommandMap })) { | ||
this.getBotInstance() | ||
.getMineflayerInstance() | ||
.chat(`/g unmute ${interaction.options.get("player_name")?.value}`); | ||
await interaction.editReply("Command has been executed!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters