Skip to content

Commit

Permalink
chore: update prettier styling (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
SachinPrasanth777 authored Jan 7, 2024
1 parent 5ec732e commit bc4ed89
Show file tree
Hide file tree
Showing 21 changed files with 132 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"singleQuote": false,
"printWidth": 120,
"tabWidth": 2,
"arrowParens": "avoid"
Expand Down
44 changes: 22 additions & 22 deletions src/commands/announce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,42 @@ import {
TextInputStyle,
EmbedBuilder,
ColorResolvable,
} from 'discord.js';
import { Command } from '../interface';
import { COLOR } from '../config/constant';
import db from '../utils/database';
import { ObjectId } from 'mongodb';
import { TemplateSchemaType } from '../types';
} from "discord.js";
import { Command } from "../interface";
import { COLOR } from "../config/constant";
import db from "../utils/database";
import { ObjectId } from "mongodb";
import { TemplateSchemaType } from "../types";

export default {
data: new SlashCommandBuilder()
.setName('announce')
.setDescription('announcement the world something')
.setName("announce")
.setDescription("announcement the world something")
.setDMPermission(false)
.addChannelOption((option: SlashCommandChannelOption) => {
return option
.setName('channel')
.setDescription('Channel to announce to')
.setName("channel")
.setDescription("Channel to announce to")
.setRequired(true)
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement);
})
.addStringOption(option =>
option.setName('id').setDescription('The template you want to use').setRequired(false),
option.setName("id").setDescription("The template you want to use").setRequired(false),
) as SlashCommandBuilder,

async execute(interaction) {
if (!interaction.guild) return;

const channelId = (interaction.options.getChannel('channel')?.id || interaction.channelId) as string;
const templateId = interaction.options.getString('id');
const channelId = (interaction.options.getChannel("channel")?.id || interaction.channelId) as string;
const templateId = interaction.options.getString("id");

if (templateId) {
const data = await (await db())
.collection<TemplateSchemaType>('templates')
.collection<TemplateSchemaType>("templates")
.findOne({ _id: new ObjectId(templateId), isDeleted: false });

if (!data) {
await interaction.reply({ content: 'Did not find a template with that ID', ephemeral: true });
await interaction.reply({ content: "Did not find a template with that ID", ephemeral: true });
return;
}

Expand All @@ -55,12 +55,12 @@ export default {
const channel = interaction.guild.channels.cache.get(channelId);

if (!channel) {
await interaction.reply({ content: 'Target Channel Not Found', ephemeral: true });
await interaction.reply({ content: "Target Channel Not Found", ephemeral: true });
return;
}

if (channel.type !== ChannelType.GuildText && channel.type !== ChannelType.GuildAnnouncement) {
await interaction.reply({ content: 'Invalid Channel Provided. Please Provide a text channel' });
await interaction.reply({ content: "Invalid Channel Provided. Please Provide a text channel" });
return;
}

Expand All @@ -70,14 +70,14 @@ export default {
return;
}

const modal = new ModalBuilder().setCustomId(`announce-${channelId}`).setTitle('Announcements');
const modal = new ModalBuilder().setCustomId(`announce-${channelId}`).setTitle("Announcements");
const Title = new TextInputBuilder()
.setCustomId('Title')
.setLabel('Provide us with the Title')
.setCustomId("Title")
.setLabel("Provide us with the Title")
.setStyle(TextInputStyle.Short);
const Description = new TextInputBuilder()
.setCustomId('Description')
.setLabel('Provide us with some Description')
.setCustomId("Description")
.setLabel("Provide us with some Description")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(Title);
Expand Down
42 changes: 21 additions & 21 deletions src/commands/echo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,68 @@ import {
SlashCommandChannelOption,
TextInputBuilder,
TextInputStyle,
} from 'discord.js';
import { Command } from '../interface';
import db from '../utils/database';
import { ObjectId } from 'mongodb';
import { TemplateSchemaType } from '../types';
} from "discord.js";
import { Command } from "../interface";
import db from "../utils/database";
import { ObjectId } from "mongodb";
import { TemplateSchemaType } from "../types";

export default {
data: new SlashCommandBuilder()
.setName('echo')
.setDescription('Announce a message to a channel')
.setName("echo")
.setDescription("Announce a message to a channel")
.setDMPermission(false)
.addChannelOption((option: SlashCommandChannelOption) => {
return option
.setName('channel')
.setDescription('Channel to announce to')
.setName("channel")
.setDescription("Channel to announce to")
.setRequired(true)
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement);
})
.addStringOption(option =>
option.setName('id').setDescription('The template you want to use').setRequired(false),
option.setName("id").setDescription("The template you want to use").setRequired(false),
) as SlashCommandBuilder,

async execute(interaction) {
if (!interaction.guild) return;
const channelId = (interaction.options.getChannel('channel')?.id || interaction.channelId) as string;
const templateId = interaction.options.getString('id');
const channelId = (interaction.options.getChannel("channel")?.id || interaction.channelId) as string;
const templateId = interaction.options.getString("id");
if (templateId) {
const data = await (await db())
.collection<TemplateSchemaType>('templates')
.collection<TemplateSchemaType>("templates")
.findOne({ _id: new ObjectId(templateId), isDeleted: false });

if (!data) {
await interaction.reply({ content: 'Did not find a template with that ID', ephemeral: true });
await interaction.reply({ content: "Did not find a template with that ID", ephemeral: true });
return;
}
const channel = interaction.guild.channels.cache.get(channelId);

if (!channel) {
await interaction.reply({ content: 'Target Channel Not Found', ephemeral: true });
await interaction.reply({ content: "Target Channel Not Found", ephemeral: true });
return;
}

if (channel.type !== ChannelType.GuildText && channel.type !== ChannelType.GuildAnnouncement) {
await interaction.reply({ content: 'Invalid Channel Provided. Please Provide a text channel' });
await interaction.reply({ content: "Invalid Channel Provided. Please Provide a text channel" });
return;
}
await channel.send({ content: `# ${data.title}\n${data.description}` });
await interaction.reply({ content: `Announcement sent to <#${channel.id}>` });
return;
}
const Title = new TextInputBuilder()
.setCustomId('Title')
.setLabel('Provide us with the Title')
.setCustomId("Title")
.setLabel("Provide us with the Title")
.setStyle(TextInputStyle.Short);
const Description = new TextInputBuilder()
.setCustomId('Description')
.setLabel('Provide us with some Description')
.setCustomId("Description")
.setLabel("Provide us with some Description")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(Title);
const secondActionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(Description);
const modal = new ModalBuilder().setCustomId(`echo-${channelId}`).setTitle('Echo Modal');
const modal = new ModalBuilder().setCustomId(`echo-${channelId}`).setTitle("Echo Modal");
modal.addComponents(firstActionRow, secondActionRow);
await interaction.showModal(modal);
},
Expand Down
8 changes: 4 additions & 4 deletions src/commands/ping.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SlashCommandBuilder } from 'discord.js';
import { Command } from '../interface';
import { SlashCommandBuilder } from "discord.js";
import { Command } from "../interface";

export default {
data: new SlashCommandBuilder().setName('ping').setDescription('Replies with Pong!').setDMPermission(false),
data: new SlashCommandBuilder().setName("ping").setDescription("Replies with Pong!").setDMPermission(false),

async execute(interaction) {
const message = await interaction.reply({ content: 'Pong!', fetchReply: true });
const message = await interaction.reply({ content: "Pong!", fetchReply: true });
await interaction.editReply(`Pong! Latency is ${Math.abs(Date.now() - message.createdTimestamp)}ms.`);
},
} as Command;
48 changes: 24 additions & 24 deletions src/commands/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,54 @@ import {
ModalBuilder,
StringSelectMenuBuilder,
SlashCommandSubcommandBuilder,
} from 'discord.js';
import { Command } from '../interface';
import db from '../utils/database';
} from "discord.js";
import { Command } from "../interface";
import db from "../utils/database";
export default {
data: new SlashCommandBuilder()
.setName('template')
.setDescription('provides us with the templates')
.setName("template")
.setDescription("provides us with the templates")
.setDMPermission(false)
.addSubcommand((subcommand: SlashCommandSubcommandBuilder) =>
subcommand.setName('create').setDescription('Creates Templates'),
subcommand.setName("create").setDescription("Creates Templates"),
)
.addSubcommand((subcommand: SlashCommandSubcommandBuilder) =>
subcommand.setName('list').setDescription('Provides us with the list'),
subcommand.setName("list").setDescription("Provides us with the list"),
)
.addSubcommand((subcommand: SlashCommandSubcommandBuilder) =>
subcommand.setName('delete').setDescription('Deletes the Templates'),
subcommand.setName("delete").setDescription("Deletes the Templates"),
) as SlashCommandBuilder,

async execute(interaction) {
if (!interaction.guild) return;
const subcommand = interaction.options.getSubcommand();

if (subcommand === 'create') {
const modal = new ModalBuilder().setCustomId(`template`).setTitle('Add Template');
if (subcommand === "create") {
const modal = new ModalBuilder().setCustomId(`template`).setTitle("Add Template");
const Title = new TextInputBuilder()
.setCustomId('Title')
.setLabel('Provide us with the Title')
.setCustomId("Title")
.setLabel("Provide us with the Title")
.setStyle(TextInputStyle.Short);

const Description = new TextInputBuilder()
.setCustomId('Description')
.setLabel('Provide us with some Description')
.setCustomId("Description")
.setLabel("Provide us with some Description")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(Title);
const secondActionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(Description);

modal.addComponents(firstActionRow, secondActionRow);
await interaction.showModal(modal);
} else if (subcommand === 'delete') {
} else if (subcommand === "delete") {
const data = await (await db())
.collection('templates')
.collection("templates")
.find({ guildId: interaction.guildId, isDeleted: false })
.toArray();

if (data.length === 0) {
await interaction.reply({
content: 'No Templates found! use `/template create` to create one!',
content: "No Templates found! use `/template create` to create one!",
ephemeral: true,
});
return;
Expand All @@ -67,16 +67,16 @@ export default {

const selectMenu = new StringSelectMenuBuilder()
.setCustomId(`deleteTemplate`)
.setPlaceholder('Select a template to delete')
.setPlaceholder("Select a template to delete")
.addOptions(templatesData);

const actionRow = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu);
await interaction.reply({ content: 'Select a template to delete:', components: [actionRow], ephemeral: true });
} else if (subcommand === 'list') {
await interaction.reply({ content: "Select a template to delete:", components: [actionRow], ephemeral: true });
} else if (subcommand === "list") {
const data = await (
await db()
)
.collection('templates')
.collection("templates")
.find({
guildId: interaction.guildId,
isDeleted: false,
Expand All @@ -85,7 +85,7 @@ export default {

if (data.length === 0) {
await interaction.reply({
content: 'No Templates found! use `/template create` to create one!',
content: "No Templates found! use `/template create` to create one!",
ephemeral: true,
});
return;
Expand All @@ -99,10 +99,10 @@ export default {

const selectMenu = new StringSelectMenuBuilder()
.setCustomId(`chooseTemplate`)
.setPlaceholder('Select a template')
.setPlaceholder("Select a template")
.addOptions(templatesData);
const actionRow = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu);
await interaction.reply({ content: 'Select a template', components: [actionRow], ephemeral: true });
await interaction.reply({ content: "Select a template", components: [actionRow], ephemeral: true });
}
},
} as Command;
2 changes: 1 addition & 1 deletion src/config/constant.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const COLOR = {
WHITE: '#FFFFFF',
WHITE: "#FFFFFF",
};
6 changes: 3 additions & 3 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { config } from 'dotenv';
import { z } from 'zod';
import { config } from "dotenv";
import { z } from "zod";

config();

const envSchema = z.object({
DISCORD_TOKEN: z.string(),
DISCORD_CLIENT_ID: z.string(),
GUILD_ID: z.string(),
NODE_ENV: z.string().optional().default('development'),
NODE_ENV: z.string().optional().default("development"),
DATABASE_URI: z.string(),
});

Expand Down
Loading

0 comments on commit bc4ed89

Please sign in to comment.