Skip to content

Commit

Permalink
πŸ”– 0.3.1
Browse files Browse the repository at this point in the history
commit be217b1
Author: Evan Elias Young <[email protected]>
Date:   Mon Mar 14 17:52:55 2022 -0500

    πŸ”– 0.3.1

commit fe879d7
Author: Evan Elias Young <[email protected]>
Date:   Mon Mar 14 17:52:17 2022 -0500

    ✨ warn user about guild commands in DMs

commit eb18b10
Author: Evan Elias Young <[email protected]>
Date:   Mon Mar 14 16:21:35 2022 -0500

    ✨ add source to about-bot
  • Loading branch information
evaneliasyoung committed Mar 14, 2022
1 parent 28289d5 commit a81de3e
Show file tree
Hide file tree
Showing 23 changed files with 102 additions and 29 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "triangle-chan",
"version": "0.3.0",
"version": "0.3.1",
"description": "Triangle Fraternity's own waifu Discord bot!",
"keywords": [
"bot",
Expand Down
6 changes: 5 additions & 1 deletion src/commands/category/add.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ export abstract class CategoryAddCommand {
})
async execute(interaction: CommandInteraction) {
if (!interaction.guildId)
return log.error(`GuildID did not exist on interaction.`);
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/category-add` can only be used in a server.',
});

const categories = await GET_GUILD_CATEGORIES(interaction.guildId);

if (!categories.length) {
Expand Down
5 changes: 4 additions & 1 deletion src/commands/category/create.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export abstract class CategoryCreateCommand {
interaction: CommandInteraction
) {
if (!interaction.guildId)
return log.error(`GuildID did not exist on interaction.`);
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/category-create` can only be used in a server.',
});

if (!name)
return await interaction
Expand Down
5 changes: 4 additions & 1 deletion src/commands/category/edit.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export abstract class CategoryEditCommand {
interaction: CommandInteraction
) {
if (!interaction.guildId)
return log.error(`GuildID did not exist on interaction.`);
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/category-edit` can only be used in a server.',
});

if (!newName && !newDesc && mutuallyExclusive === null) {
log.debug(`User didn't change anything about the category`);
Expand Down
5 changes: 4 additions & 1 deletion src/commands/category/list.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export abstract class CategoryListCommand {
})
async execute(interaction: CommandInteraction) {
if (!interaction.guildId)
return log.error(`GuildID did not exist on interaction.`);
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/category-list` can only be used in a server.',
});

const categories = await GET_GUILD_CATEGORIES(interaction.guildId).catch(
MessageWithErrorHandler(
Expand Down
5 changes: 4 additions & 1 deletion src/commands/category/remove.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export abstract class CategoryRemoveCommand {
interaction: CommandInteraction
) {
if (!interaction.guildId)
return log.error(`GuildID did not exist on interaction.`);
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/category-remove` can only be used in a server.',
});

if (!name) {
log.debug(
Expand Down
5 changes: 4 additions & 1 deletion src/commands/category/update.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export abstract class CategoryUpdateCommand {
interaction: CommandInteraction
) {
if (!interaction.guildId)
return log.error(`GuildID did not exist on interaction.`);
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/category-update` can only be used in a server.',
});

if (!messageLink) {
log.error(
Expand Down
5 changes: 4 additions & 1 deletion src/commands/counter/create.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ export abstract class CounterCreateCommand {
interaction: CommandInteraction
) {
if (!interaction.guildId)
return log.error(`GuildID did not exist on interaction.`);
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/counter-create` can only be used in a server.',
});

if (!isVoiceChannel(channel))
return await interaction
Expand Down
5 changes: 4 additions & 1 deletion src/commands/counter/edit.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ export abstract class CounterEditCommand {
interaction: CommandInteraction
) {
if (!interaction.guildId)
return log.error(`GuildID did not exist on interaction.`);
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/counter-edit` can only be used in a server.',
});

if (!newName && !newEmoji && !newType) {
log.debug(`User didn't change anything about the counter`);
Expand Down
5 changes: 4 additions & 1 deletion src/commands/counter/list.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export abstract class CounterListCommand {
})
async execute(interaction: CommandInteraction) {
if (!interaction.guildId)
return log.error(`GuildID did not exist on interaction.`);
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/counter-list` can only be used in a server.',
});

const counters = await GET_COUNTERS_BY_GUILD_ID(interaction.guildId).catch(
MessageWithErrorHandler(
Expand Down
11 changes: 5 additions & 6 deletions src/commands/counter/remove.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import {CommandInteraction} from 'discord.js';
import {Discord, Slash, SlashOption} from 'discordx';
import {DELETE_COUNTER_BY_NAME} from '../../database/database.js';
import CounterService from '../../services/counter.service.js';
import {
InteractionFailedHandlerGenerator,
logger,
Expand All @@ -21,8 +20,6 @@ const InteractionFailedHandler = InteractionFailedHandlerGenerator(log);

@Discord()
export abstract class CounterRemoveCommand {
#counterService = new CounterService();

@Slash('counter-remove', {
description: 'Removes the counters from the voice channels.',
})
Expand All @@ -35,9 +32,11 @@ export abstract class CounterRemoveCommand {
name: string,
interaction: CommandInteraction
) {
const {guild, guildId} = interaction;
if (!guildId) return log.error(`GuildID did not exist on interaction.`);
if (!guild) return log.error('Guild did not exist on interaction.');
if (!interaction.guildId)
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/counter-remove` can only be used in a server.',
});

if (!name) {
log.error(`Required option name was undefined.`);
Expand Down
9 changes: 6 additions & 3 deletions src/commands/counter/sync.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ export abstract class CounterSyncCommand {
description: 'Syncs the counts of the counter channels.',
})
async execute(interaction: CommandInteraction) {
const {guild, guildId} = interaction;
if (!guildId) return log.error(`GuildID did not exist on interaction.`);
if (!guild) return log.error('Guild did not exist on interaction.');
const {guild} = interaction;
if (!guild)
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/counter-` can only be used in a server.',
});

try {
await this.#counterService.handleGuild(guild);
Expand Down
5 changes: 4 additions & 1 deletion src/commands/react/channel.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export abstract class ReactChannelCommand {
interaction: CommandInteraction
) {
if (!interaction.guildId)
return log.error(`GuildID did not exist on interaction.`);
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/react-channel` can only be used in a server.',
});

try {
await interaction
Expand Down
6 changes: 5 additions & 1 deletion src/commands/react/list.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export abstract class ReactListCommand {
description: 'List all reaction roles that are currently active.',
})
async execute(interaction: CommandInteraction) {
if (!interaction.isCommand() || !interaction.guildId) return;
if (!interaction.guildId)
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/react-list` can only be used in a server.',
});

const reactRoles = await GET_REACT_ROLES_BY_GUILD_ID(
interaction.guildId
Expand Down
6 changes: 5 additions & 1 deletion src/commands/react/message.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ export abstract class ReactMessageCommand {
messageLink: string,
interaction: CommandInteraction
) {
if (!interaction.isCommand() || !interaction.guildId) return;
if (!interaction.guildId)
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/react-message` can only be used in a server.',
});

if (!messageLink)
return await interaction
Expand Down
6 changes: 6 additions & 0 deletions src/commands/react/nuke.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export abstract class ReactNukeCommand {
description: 'This will remove ALL react roles for this server.',
})
async execute(interaction: CommandInteraction) {
if (!interaction.guildId)
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/react-nuke` can only be used in a server.',
});

const buttons = new MessageActionRow({
components: [
new MessageButton({
Expand Down
6 changes: 6 additions & 0 deletions src/commands/react/remove.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export abstract class ReactRemoveCommand {
role: Role,
interaction: CommandInteraction
) {
if (!interaction.guildId)
return await interaction.reply({
ephemeral: true,
content: 'Hey! `/react-` can only be used in a server.',
});

if (!role) {
log.error(
`Interaction was missing role property despite it being required.`
Expand Down
8 changes: 7 additions & 1 deletion src/commands/react/role.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ export abstract class ReactRoleCommand {
emoji: string,
interaction: CommandInteraction
) {
if (!interaction.isCommand() || !interaction.guildId) return;
if (!interaction.guildId)
return await interaction
.reply({
ephemeral: true,
content: 'Hey! `/react-role` can only be used in a server.',
})
.catch(InteractionFailedHandler);

const {guild} = interaction;
if (!guild) return;
Expand Down
8 changes: 8 additions & 0 deletions src/commands/role/appoint.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ export default abstract class RoleAppointCommand {
role: Role,
interaction: CommandInteraction
) {
if (!interaction.guildId)
return await interaction
.reply({
ephemeral: true,
content: 'Hey! `/role-appoint` can only be used in a server.',
})
.catch(InteractionFailedHandler);

if (role.members.has(user.id))
return await interaction
.reply({
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author Evan Elias Young
* @date 2022-03-05
* @date 2022-03-11
* @date 2022-03-14
* @copyright Copyright 2022 Evan Elias Young. All rights reserved.
*/

Expand Down Expand Up @@ -34,6 +34,8 @@ import {
ReactMessage,
ReactRole,
} from './database/database.js';
import PermissionService from './services/permission.service.js';
const permissionService = new PermissionService();
const log = logger(import.meta);
const MessageWithErrorHandler = MessageWithErrorHandlerGenerator(log);

Expand All @@ -49,6 +51,8 @@ const client = new Client({
partials: ['MESSAGE', 'REACTION', 'CHANNEL', 'GUILD_MEMBER'],
});

permissionService.client = client;

async function run() {
const path: string = `${__dirname}/{events,commands}/**/*.ts`;

Expand Down
3 changes: 2 additions & 1 deletion src/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
*
* @author Evan Elias Young
* @date 2022-03-09
* @date 2022-03-13
* @date 2022-03-14
* @copyright Copyright 2022 Evan Elias Young. All rights reserved.
*/

import {ActivitiesOptions} from 'discord.js';
import {DateTime} from 'luxon';

export namespace BotInfo {
export const source = '[GitHub](https://github.com/evaneliasyoung/triangle-chan)'
export const tagline = `Triangle-Chan: The Tenaciously Tasteful Discord Tease`;
export const library =
'[discord.ts / Node](https://github.com/oceanroleplay/discord.ts)';
Expand Down
5 changes: 3 additions & 2 deletions src/services/embed.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author Evan Elias Young
* @date 2022-03-05
* @date 2022-03-13
* @date 2022-03-14
* @copyright Copyright 2022 Evan Elias Young. All rights reserved.
*/

Expand Down Expand Up @@ -278,9 +278,10 @@ export default class EmbedService {
new MessageEmbed({
description: BotInfo.tagline,
fields: [
{name: 'Author', value: 'MoM Chapter', inline: true},
{name: 'Source', value: BotInfo.source, inline: true},
{name: 'Library', value: BotInfo.library, inline: true},
{name: 'Version', value: BotInfo.version, inline: true},
{name: 'Author', value: 'MoM Chapter', inline: true},
{name: 'Date', value: dateToISO(BotInfo.date), inline: true},
{
name: 'Servers',
Expand Down

0 comments on commit a81de3e

Please sign in to comment.