Compare commits
2 commits
4b6a413f85
...
cdbe79f2a2
Author | SHA1 | Date | |
---|---|---|---|
powermaker450 | cdbe79f2a2 | ||
powermaker450 | fb8a9500e7 |
|
@ -21,6 +21,7 @@ import { commands } from "../commands";
|
||||||
import { BOT_ID, BOT_TOKEN } from "./config";
|
import { BOT_ID, BOT_TOKEN } from "./config";
|
||||||
import { DeployCommandsProps } from "./types";
|
import { DeployCommandsProps } from "./types";
|
||||||
import Logger from "../utils/Logger";
|
import Logger from "../utils/Logger";
|
||||||
|
import { BotClient } from "./client";
|
||||||
|
|
||||||
const logger = new Logger("Deployer");
|
const logger = new Logger("Deployer");
|
||||||
|
|
||||||
|
@ -32,13 +33,15 @@ const rest = new REST({ version: "9" }).setToken(BOT_TOKEN);
|
||||||
|
|
||||||
export async function deployCommands({ guildId }: DeployCommandsProps) {
|
export async function deployCommands({ guildId }: DeployCommandsProps) {
|
||||||
try {
|
try {
|
||||||
logger.log("Started refreshing (/) commands.");
|
const guildName = BotClient.guilds.cache.get(guildId)?.name;
|
||||||
|
|
||||||
|
logger.log(`Started refreshing (/) commands for ${guildName}`);
|
||||||
|
|
||||||
await rest.put(Routes.applicationGuildCommands(BOT_ID, guildId), {
|
await rest.put(Routes.applicationGuildCommands(BOT_ID, guildId), {
|
||||||
body: commandsData
|
body: commandsData
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.log("Successfully reloaded (/) commands.");
|
logger.log(`Successfully reloaded (/) commands for ${guildName}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
// TODO: This all works as intended, but I'd like for it so be a reusable function
|
// TODO: This all works as intended, but I'd like for it so be a reusable function
|
||||||
// instead because all of this is used in src/main.ts
|
// instead because all of this is used in src/main.ts
|
||||||
try {
|
try {
|
||||||
|
// If the user is banned in this guild, don't let them post
|
||||||
if (dt.isBanned(interaction.guild?.id!, interaction.user.id)) {
|
if (dt.isBanned(interaction.guild?.id!, interaction.user.id)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "You are banned from confessions in this server!",
|
content: "You are banned from confessions in this server!",
|
||||||
|
@ -61,6 +62,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no guild info is present for this guild, don't let the user post
|
||||||
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content:
|
content:
|
||||||
|
@ -82,6 +84,15 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
const color = getRandomColor();
|
const color = getRandomColor();
|
||||||
const messageId = StoreMan.genId();
|
const messageId = StoreMan.genId();
|
||||||
|
|
||||||
|
// Looks like:
|
||||||
|
//
|
||||||
|
// |
|
||||||
|
// | Anonymous Confession a1b2
|
||||||
|
// |
|
||||||
|
// | "example confession content"
|
||||||
|
// |
|
||||||
|
//
|
||||||
const userConfessionEmbed = new EmbedBuilder()
|
const userConfessionEmbed = new EmbedBuilder()
|
||||||
.setColor(color)
|
.setColor(color)
|
||||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
|
@ -89,6 +100,20 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
isAttachment(attachment) && userConfessionEmbed.setImage(attachment);
|
isAttachment(attachment) && userConfessionEmbed.setImage(attachment);
|
||||||
|
|
||||||
|
// Looks like:
|
||||||
|
//
|
||||||
|
// |
|
||||||
|
// | Anonymous Confession a1b2
|
||||||
|
// |
|
||||||
|
// | "example confession content"
|
||||||
|
// |
|
||||||
|
// | Author
|
||||||
|
// | @user1
|
||||||
|
// |
|
||||||
|
// | Author ID
|
||||||
|
// | 1234567890
|
||||||
|
// |
|
||||||
|
//
|
||||||
const adminConfessionEmbed = new EmbedBuilder()
|
const adminConfessionEmbed = new EmbedBuilder()
|
||||||
.setColor(color)
|
.setColor(color)
|
||||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
|
@ -148,6 +173,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
const confessionsLength = dt.getGuildInfo(interaction.guild?.id!)
|
const confessionsLength = dt.getGuildInfo(interaction.guild?.id!)
|
||||||
?.confessions.length!;
|
?.confessions.length!;
|
||||||
|
|
||||||
|
// If there are 2 or more confessions, remove the previous confession's button components
|
||||||
if (confessionsLength >= 2) {
|
if (confessionsLength >= 2) {
|
||||||
await (
|
await (
|
||||||
BotClient.channels.cache.get(confessChannel!) as TextChannel
|
BotClient.channels.cache.get(confessChannel!) as TextChannel
|
||||||
|
|
|
@ -35,6 +35,15 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
? "Banned Members:\n"
|
? "Banned Members:\n"
|
||||||
: "There are no banned members.";
|
: "There are no banned members.";
|
||||||
|
|
||||||
|
// For each member, add them to the message content.
|
||||||
|
// It will end up looking something like this:
|
||||||
|
//
|
||||||
|
// Banned Members:
|
||||||
|
//
|
||||||
|
// @user1 | a1b2
|
||||||
|
// @user2 | c3d4
|
||||||
|
// @user3 | e5f6
|
||||||
|
//
|
||||||
for (const member of bannedMembers) {
|
for (const member of bannedMembers) {
|
||||||
content += `\n<@${member.user}> | \`${member.confessionId}\``;
|
content += `\n<@${member.user}> | \`${member.confessionId}\``;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
CommandInteraction,
|
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
TextChannel
|
TextChannel
|
||||||
|
@ -38,6 +37,8 @@ export const data = new SlashCommandBuilder()
|
||||||
);
|
);
|
||||||
|
|
||||||
export async function execute(interaction: ChatInputCommandInteraction) {
|
export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
|
// If there is no guild info, don't let the user delete anything
|
||||||
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content:
|
content:
|
||||||
|
@ -49,6 +50,8 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
const idVal = interaction.options.getString("id")!;
|
const idVal = interaction.options.getString("id")!;
|
||||||
const result = dt.getConfession(interaction.guild?.id!, idVal);
|
const result = dt.getConfession(interaction.guild?.id!, idVal);
|
||||||
|
|
||||||
|
// If a confession is found with the given ID, check if the user is the one that posted it, and delete it if they are.
|
||||||
|
// Otherwise, don't let the user delete anything.
|
||||||
if (result) {
|
if (result) {
|
||||||
try {
|
try {
|
||||||
const confession = dt.getConfession(
|
const confession = dt.getConfession(
|
||||||
|
@ -60,9 +63,9 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
const emptyEmbed = new EmbedBuilder()
|
const emptyEmbed = new EmbedBuilder()
|
||||||
.setColor(getRandomColor())
|
.setColor(getRandomColor())
|
||||||
.setTitle("Confession Deleted")
|
.setTitle("Confession Deleted")
|
||||||
// @ts-ignore
|
|
||||||
.setDescription("[Confession Deleted]");
|
.setDescription("[Confession Deleted]");
|
||||||
|
|
||||||
|
// Replace the given confession with an empty embed
|
||||||
await (BotClient.channels.cache.get(channelId) as TextChannel).messages
|
await (BotClient.channels.cache.get(channelId) as TextChannel).messages
|
||||||
.fetch(confession!)
|
.fetch(confession!)
|
||||||
.then(e => {
|
.then(e => {
|
||||||
|
|
Loading…
Reference in a new issue