-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kevin Siniecki
committed
Nov 28, 2023
1 parent
30878d6
commit 8c146f6
Showing
5 changed files
with
146 additions
and
46 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
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,94 @@ | ||
import { | ||
ApplicationCommandOptionType, | ||
ChannelType, | ||
GuildChannel, | ||
Message, | ||
TextChannel as DiscordTextChannel, | ||
} from "discord.js"; | ||
import { Command } from "../../typings"; | ||
import { GuildModel } from "../models/guilds"; | ||
import { FilterOutFunctionKeys } from "@typegoose/typegoose/lib/types"; | ||
import {TextChannel} from "../models/text_channels"; | ||
|
||
const command: Command = { | ||
name: "setqueueinfo", | ||
description: "the given text chnnel will inform tutors with active sessions about queue activities", | ||
aliases: ["sqi"], | ||
usage: "[channel resolvable]", | ||
cooldown: 5, | ||
category: "Coaching", | ||
guildOnly: true, | ||
defaultPermission: false, | ||
options: [{ | ||
name: "queueinfochannel", | ||
description: "the text channels name", | ||
type: ApplicationCommandOptionType.Channel, | ||
required: true, | ||
}, | ||
{ | ||
name: "queue", | ||
description: "name of the queue", | ||
type: ApplicationCommandOptionType.String, | ||
required: true, | ||
} | ||
], | ||
execute: async (client, interaction, args) => { | ||
if (!interaction) { | ||
return; | ||
} | ||
if (interaction instanceof Message) { | ||
await client.utils.embeds.SimpleEmbed(interaction, { title: "Slash Only Command", text: "This Command is Slash only but you Called it with The Prefix. use the slash Command instead.", deleteinterval: 3000 }); | ||
if (interaction.deletable) await interaction.delete(); | ||
return; | ||
} | ||
const member = client.utils.general.getMember(interaction); | ||
if (!member || member.id !== client.config.get("ownerID") as string) { | ||
await interaction?.reply("You do not have permission to execute this command."); | ||
return; | ||
} | ||
|
||
|
||
// Find channel | ||
const channel = interaction.options.getChannel("queueinfochannel", true); | ||
if (!channel || !(channel instanceof GuildChannel)) { | ||
return await interaction?.reply("Channel could not be found."); | ||
} | ||
if (!(channel instanceof DiscordTextChannel)) { | ||
return await interaction?.reply("QueueInfoChannel channel must be a text Channel."); | ||
} | ||
|
||
const g = interaction!.guild!; | ||
const guildData = (await GuildModel.findById(g.id)); | ||
|
||
if (!guildData) { | ||
return await client.utils.embeds.SimpleEmbed(interaction, { title: "Coaching System", text: "Guild Data Could not be found.", empheral: true }); | ||
} | ||
|
||
const queue = interaction.options.getString("queue", true); | ||
const queueData = guildData.queues.find(x => x.name === queue); | ||
|
||
const updated = await GuildModel.updateOne( | ||
{ _id: g.id }, | ||
{ | ||
$push: { | ||
"text_channels": { | ||
_id: channel.id, | ||
managed: true, | ||
channel_type : ChannelType.GroupDM, | ||
queue: queueData, | ||
listen_for_commands: true, | ||
category: channel.parent?.name | ||
} as FilterOutFunctionKeys<TextChannel>, | ||
}, | ||
}, | ||
{ upsert: true, setDefaultsOnInsert: true }, | ||
); | ||
console.log(updated); | ||
interaction!.reply({ content: `Success. ${channel.name} set to queue info channel for queue: ${queue}` }); | ||
}, | ||
}; | ||
|
||
/** | ||
* Exporting the Command using CommonJS | ||
*/ | ||
module.exports = command; |
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
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
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