Proper typings(?)
This commit is contained in:
parent
29d15301cb
commit
25a386cf1a
|
@ -20,7 +20,7 @@ import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
ButtonStyle,
|
ButtonStyle,
|
||||||
CommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
ComponentType,
|
ComponentType,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
|
@ -50,7 +50,7 @@ export const data = new SlashCommandBuilder()
|
||||||
.setDescription("The link to an image to attach (optional)")
|
.setDescription("The link to an image to attach (optional)")
|
||||||
);
|
);
|
||||||
|
|
||||||
export async function execute(interaction: CommandInteraction) {
|
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 reused in src/main.ts:56
|
// instead because all of this is reused in src/main.ts:56
|
||||||
try {
|
try {
|
||||||
|
@ -73,12 +73,11 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
.confessChannel;
|
.confessChannel;
|
||||||
const adminChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
const adminChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
||||||
.modChannel;
|
.modChannel;
|
||||||
// @ts-ignore
|
|
||||||
const messageContent: string = `"${interaction.options.getString("message")}"`;
|
|
||||||
// @ts-ignore
|
|
||||||
const attachment: string = interaction.options.getString("attachment");
|
|
||||||
|
|
||||||
const isAttachment = (text: string) =>
|
const messageContent = `"${interaction.options.getString("message")}"`;
|
||||||
|
const attachment = interaction.options.getString("attachment")!;
|
||||||
|
|
||||||
|
const isAttachment = (text: string | null) =>
|
||||||
text && (text.startsWith("http://") || text.startsWith("https://"));
|
text && (text.startsWith("http://") || text.startsWith("https://"));
|
||||||
|
|
||||||
const color = getRandomColor();
|
const color = getRandomColor();
|
||||||
|
@ -86,7 +85,6 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
const userConfessionEmbed = new EmbedBuilder()
|
const userConfessionEmbed = new EmbedBuilder()
|
||||||
.setColor(color)
|
.setColor(color)
|
||||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
// @ts-ignore
|
|
||||||
.setDescription(messageContent);
|
.setDescription(messageContent);
|
||||||
|
|
||||||
isAttachment(attachment) && userConfessionEmbed.setImage(attachment);
|
isAttachment(attachment) && userConfessionEmbed.setImage(attachment);
|
||||||
|
@ -94,7 +92,6 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
const adminConfessionEmbed = new EmbedBuilder()
|
const adminConfessionEmbed = new EmbedBuilder()
|
||||||
.setColor(color)
|
.setColor(color)
|
||||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
// @ts-ignore
|
|
||||||
.setDescription(messageContent)
|
.setDescription(messageContent)
|
||||||
.addFields(
|
.addFields(
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
PermissionFlagsBits,
|
PermissionFlagsBits,
|
||||||
SlashCommandBuilder
|
SlashCommandBuilder
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
|
@ -37,11 +37,10 @@ export const data = new SlashCommandBuilder()
|
||||||
)
|
)
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers);
|
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers);
|
||||||
|
|
||||||
export async function execute(interaction: CommandInteraction) {
|
export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
const result = dt.addBan(
|
const result = dt.addBan(
|
||||||
interaction.guild?.id!,
|
interaction.guild?.id!,
|
||||||
// @ts-ignore
|
interaction.options.getString("id")!
|
||||||
interaction.options.getString("id")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
ChatInputCommandInteraction,
|
||||||
CommandInteraction,
|
CommandInteraction,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
|
@ -36,7 +37,7 @@ export const data = new SlashCommandBuilder()
|
||||||
option.setName("id").setDescription("The confession id").setRequired(true)
|
option.setName("id").setDescription("The confession id").setRequired(true)
|
||||||
);
|
);
|
||||||
|
|
||||||
export async function execute(interaction: CommandInteraction) {
|
export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content:
|
content:
|
||||||
|
@ -45,8 +46,7 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
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 (result) {
|
if (result) {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
PermissionFlagsBits,
|
PermissionFlagsBits,
|
||||||
SlashCommandBuilder
|
SlashCommandBuilder
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
|
@ -37,11 +37,10 @@ export const data = new SlashCommandBuilder()
|
||||||
)
|
)
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages);
|
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages);
|
||||||
|
|
||||||
export function execute(interaction: CommandInteraction) {
|
export function execute(interaction: ChatInputCommandInteraction) {
|
||||||
const result = dt.removeBan(
|
const result = dt.removeBan(
|
||||||
interaction.guild?.id!,
|
interaction.guild?.id!,
|
||||||
// @ts-ignore
|
interaction.options.getString("id")!
|
||||||
interaction.options.getString("id")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
ButtonStyle,
|
ButtonStyle,
|
||||||
|
ChatInputCommandInteraction,
|
||||||
ComponentType,
|
ComponentType,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
Events,
|
Events,
|
||||||
|
@ -58,7 +59,9 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
||||||
const { commandName } = interaction;
|
const { commandName } = interaction;
|
||||||
|
|
||||||
if (commands[commandName as keyof typeof commands]) {
|
if (commands[commandName as keyof typeof commands]) {
|
||||||
commands[commandName as keyof typeof commands].execute(interaction);
|
commands[commandName as keyof typeof commands].execute(
|
||||||
|
interaction as ChatInputCommandInteraction
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue