Merge branch 'dev' into 'main'

Dev

See merge request illegitimate/illegitimate-bot!159
This commit is contained in:
2024-01-04 21:14:08 +00:00
14 changed files with 260 additions and 26 deletions

View File

@@ -11,5 +11,6 @@
"defaultMember": "722386801930797056",
"admin": "528549814846095360",
"helper": "592371991294771226",
"muted": "594355088932339732"
"muted": "594355088932339732",
"countingBanned": "1192183486128341072"
}

View File

@@ -5,17 +5,17 @@ import { Command } from "../src/interfaces"
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!)
const commands: RESTPutAPIApplicationCommandsJSONBody = []
const commandFiles = fs.readdirSync("./dist/src/commands/").filter(file => file.endsWith(".js"))
const contentMenuCommands = fs.readdirSync("./dist/src/commands-contextmenu/").filter(file => file.endsWith(".js"))
const commandFiles = fs.readdirSync("./src/commands/").filter(file => file.endsWith(".ts"))
const contentMenuCommands = fs.readdirSync("./src/commands-contextmenu/").filter(file => file.endsWith(".ts"))
for (const file of commandFiles) {
const command: Command = require(`../dist/src/commands/${file}`)
const command: Command = require(`../src/commands/${file}`)
if (command.dev) {
commands.push(command.data.toJSON())
}
}
for (const file of contentMenuCommands) {
const command: Command = require(`../dist/src/commands-contextmenu/${file}`)
const command: Command = require(`../src/commands-contextmenu/${file}`)
if (command.dev) {
commands.push(command.data.toJSON())
}

91
src/commands/counting.ts Normal file
View File

@@ -0,0 +1,91 @@
import { ChannelType, PermissionFlagsBits, SlashCommandBuilder } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
import setup from "./counting/setup"
import ban from "./counting/ban"
import unban from "./counting/unban"
export = {
name: "counting",
description: "counting subcommands",
type: "slash",
dev: false,
public: true,
subcommands: true,
data: new SlashCommandBuilder()
.setName("counting")
.setDescription("counting subcommands")
.addSubcommand(subcommand =>
subcommand
.setName("setup")
.setDescription("Setup counting channel")
.addChannelOption(option =>
option
.setName("channel")
.setDescription("The channel to setup counting in")
.setRequired(true)
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
),
)
.addSubcommand(subcommand =>
subcommand
.setName("ban")
.setDescription("Ban a user from counting")
.addUserOption(option =>
option
.setName("user")
.setDescription("The user to ban")
.setRequired(true)
)
)
.addSubcommand(subcommand =>
subcommand
.setName("unban")
.setDescription("Unban a user from counting")
.addUserOption(option =>
option
.setName("user")
.setDescription("The user to ban")
.setRequired(true)
)
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
const subcommand = interaction.options.getSubcommand()
const embedColor = Number(color.replace("#", "0x"))
if (subcommand === "setup") {
setup(interaction)
return
}
if (subcommand === "ban") {
ban(interaction)
return
}
if (subcommand === "unban") {
unban(interaction)
return
}
await interaction.reply({
embeds: [
{
description: "This command is currently under development",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url:
interaction.guild!.iconURL({
forceStatic: false,
}) || undefined,
},
},
],
})
},
} as Command

View File

@@ -0,0 +1,52 @@
import {
ChatInputCommandInteraction,
GuildMember,
userMention,
} from "discord.js"
import { countingBanned } from "../../../config/roles.json"
import { color, devMessage } from "../../../config/options.json"
export default async function ban(
interaction: ChatInputCommandInteraction,
): Promise<void> {
const member = interaction.options.getMember("user")! as GuildMember
const embedColor = Number(color.replace("#", "0x"))
if (member.roles.cache.has(countingBanned)) {
await interaction.reply({
embeds: [
{
description:
userMention(member.user.id) +
" is currently banned from counting",
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
text: interaction.guild!.name + " | " + devMessage,
},
},
],
})
} else {
await member.roles.add(countingBanned)
await interaction.reply({
embeds: [
{
description:
userMention(member.user.id) +
" has been banned from counting",
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
text: interaction.guild!.name + " | " + devMessage,
},
},
],
})
}
}

View File

@@ -0,0 +1,44 @@
import { ChatInputCommandInteraction, GuildTextBasedChannel, channelMention } from "discord.js"
import settingsSchema from "../../schemas/settingsSchema"
import { color, devMessage } from "../../../config/options.json"
import mongoose from "mongoose"
export default async function setup(interaction: ChatInputCommandInteraction): Promise<void> {
await interaction.deferReply()
const channel = interaction.options.getChannel("channel") as GuildTextBasedChannel
const embedColor = Number(color.replace("#", "0x"))
if (await settingsSchema.findOne({ name: "counting" })) {
await settingsSchema.findOneAndUpdate({ name: "counting" }, { name: "counting", channel: channel.id })
await interaction.editReply({
embeds: [{
description: "Counting channel has been updated to " + channelMention(channel.id),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({ forceStatic: false })!,
text: interaction.guild!.name + " | " + devMessage
}
}]
})
} else {
const counting = new settingsSchema({
_id: new mongoose.Types.ObjectId(),
name: "counting",
value: channel.id
})
await counting.save()
await interaction.editReply({
embeds: [{
description: "Counting channel has been set to " + channelMention(channel.id),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({ forceStatic: false })!,
text: interaction.guild!.name + " | " + devMessage
}
}]
})
}
}

View File

@@ -0,0 +1,52 @@
import {
ChatInputCommandInteraction,
GuildMember,
userMention,
} from "discord.js"
import { countingBanned } from "../../../config/roles.json"
import { color, devMessage } from "../../../config/options.json"
export default async function ban(
interaction: ChatInputCommandInteraction,
): Promise<void> {
const member = interaction.options.getMember("user")! as GuildMember
const embedColor = Number(color.replace("#", "0x"))
if (!member.roles.cache.has(countingBanned)) {
await interaction.reply({
embeds: [
{
description:
userMention(member.user.id) +
" is currently not banned from counting",
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
text: interaction.guild!.name + " | " + devMessage,
},
},
],
})
} else {
await member.roles.remove(countingBanned)
await interaction.reply({
embeds: [
{
description:
userMention(member.user.id) +
" has been unbanned from counting",
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
text: interaction.guild!.name + " | " + devMessage,
},
},
],
})
}
}

View File

@@ -1,9 +1,9 @@
import { SlashCommandBuilder } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
import guildMember = require("./guild/member")
import guildInfo = require("./guild/info")
import guildTop = require("./guild/top")
import guildMember from "./guild/member"
import guildInfo from "./guild/info"
import guildTop from "./guild/top"
export = {
name: "guild",

View File

@@ -9,7 +9,7 @@ import { color, devMessage } from "../../../config/options.json"
import { ChatInputCommandInteraction } from "discord.js"
import { GuildData } from "../../interfaces/Guild"
async function guildInfo(
export default async function guildInfo(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
@@ -242,5 +242,3 @@ async function guildInfo(
],
})
}
export = guildInfo

View File

@@ -2,7 +2,7 @@ import { getUUID, getPlayer, getGuild, getHeadURL } from "../../utils/Hypixel"
import { color, devMessage } from "../../../config/options.json"
import { ChatInputCommandInteraction } from "discord.js"
async function guildMember(
export default async function guildMember(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
@@ -212,5 +212,3 @@ async function guildMember(
],
})
}
export = guildMember

View File

@@ -5,7 +5,7 @@ import { GuildData } from "../../interfaces/Guild"
import Illegitimate from "../../utils/Illegitimate"
const redis = Illegitimate.redis
async function guildTop(
export default async function guildTop(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
@@ -292,5 +292,3 @@ async function guildTop(
],
})
}
export = guildTop

View File

@@ -1,9 +1,9 @@
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
import { help } from "./staff/help"
import { beast } from "./staff/beast"
import { updateDiscordRoles } from "./staff/updatediscordroles"
import help from "./staff/help"
import beast from "./staff/beast"
import updateDiscordRoles from "./staff/updatediscordroles"
export = {
name: "staff",

View File

@@ -19,7 +19,7 @@ import {
} from "../../utils/Hypixel"
import { ChatInputCommandInteraction } from "discord.js"
export async function beast(
export default async function beast(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()

View File

@@ -2,7 +2,7 @@ import { ChatInputCommandInteraction } from "discord.js"
import { color, devMessage } from "../../../config/options.json"
import { ExtendedClient as Client } from "../../utils/Client"
export async function help(
export default async function help(
interaction: ChatInputCommandInteraction,
client: Client,
): Promise<void> {

View File

@@ -6,7 +6,7 @@ import env from "../../utils/Env"
import { getGuild } from "../../utils/Hypixel"
import { GuildData } from "../../interfaces"
export async function updateDiscordRoles(
export default async function updateDiscordRoles(
interaction: ChatInputCommandInteraction,
): Promise<void> {
const discordMember = interaction.member as GuildMember