Starting the counting system
This commit is contained in:
@@ -11,5 +11,6 @@
|
|||||||
"defaultMember": "722386801930797056",
|
"defaultMember": "722386801930797056",
|
||||||
"admin": "528549814846095360",
|
"admin": "528549814846095360",
|
||||||
"helper": "592371991294771226",
|
"helper": "592371991294771226",
|
||||||
"muted": "594355088932339732"
|
"muted": "594355088932339732",
|
||||||
|
"countingBanned": "1192183486128341072"
|
||||||
}
|
}
|
||||||
|
|||||||
91
src/commands/counting.ts
Normal file
91
src/commands/counting.ts
Normal 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: true,
|
||||||
|
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
|
||||||
52
src/commands/counting/ban.ts
Normal file
52
src/commands/counting/ban.ts
Normal 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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
44
src/commands/counting/setup.ts
Normal file
44
src/commands/counting/setup.ts
Normal 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
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
52
src/commands/counting/unban.ts
Normal file
52
src/commands/counting/unban.ts
Normal 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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user