Skip to content

Commit

Permalink
move client_id to env and try out release-it
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed Jun 26, 2024
1 parent 84ef080 commit 824f5d9
Show file tree
Hide file tree
Showing 10 changed files with 2,367 additions and 70 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CLIENT_ID="discord bot's CLIENT_ID (usually the same as the user ID)"
TOKEN="discord bot token here"
DATABASE_URL="mongodb connection url here" # get it from mongodb atlas or use local mongodb
TOPGG_API_KEY="your topgg bot access token>" # not required if you don't have a bot on top.gg.
Expand Down
5 changes: 5 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"npm": {
"publish": false
}
}
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ static override async handleComponents(interaction: MessageComponentInteraction)
- Commands are loaded automatically by calling the `loadCommandFiles` method from `src/managers/CommandManager.ts` during the bot startup.
- The `src/commands/BaseCommand.ts` file contains all the methods/properties that can be used in a command.
- We use the `interactionCreate` event for handling **all** interactions instead of using collectors.
- If you are using your own bot for testing, make sure to change the CLIENT_ID in `src/utils/Constants.ts` like so (don't commit this change):

```ts
export const CLIENT_ID = isDevBuild ? '<new_client_id_here>' : '769921109209907241';
```
- If you are using your own bot for testing, make sure to set the CLIENT_ID to your bot's ID in `.env`.

### Tensorflow Errors

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"lint-staged": "^15.2.7",
"prettier": "^3.3.2",
"prisma": "^5.15.0",
"release-it": "^17.4.0",
"standard-version": "^9.5.0",
"tsc-watch": "^6.2.0",
"typescript": "^5.4.5",
Expand Down
9 changes: 9 additions & 0 deletions src/commands/slash/Main/hub/invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ export default class Invite extends Hub {
});
return;
}

if (!Date.parse(expires.toString())) {
await interaction.reply({
embeds: [simpleEmbed(`${emojis.no} Invalid Expiry Duration provided!`)],
ephemeral: true,
});
return;
}

const createdInvite = await db.hubInvites.create({
data: {
hub: { connect: { name: hubName } },
Expand Down
10 changes: 5 additions & 5 deletions src/commands/slash/Staff/ban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {
ChatInputCommandInteraction,
RESTPostAPIChatInputApplicationCommandsJSONBody,
} from 'discord.js';
import BaseCommand from '../../../core/BaseCommand.js';
import db from '../../../utils/Db.js';
import { simpleEmbed } from '../../../utils/Utils.js';
import { DeveloperIds, emojis } from '../../../utils/Constants.js';
import BaseCommand from '../../../core/BaseCommand.js';
import { isDev, simpleEmbed } from '../../../utils/Utils.js';
import { emojis } from '../../../utils/Constants.js';

export default class Ban extends BaseCommand {
readonly staffOnly = true;
Expand All @@ -23,13 +23,13 @@ export default class Ban extends BaseCommand {
{
type: ApplicationCommandOptionType.String,
name: 'reason',
description: 'Reson for the ban',
description: 'Reason for the ban',
required: true,
},
],
};
override async execute(interaction: ChatInputCommandInteraction): Promise<unknown> {
if (!DeveloperIds.includes(interaction.user.id)) return;
if (!isDev(interaction.user.id)) return;

const user = interaction.options.getUser('user', true);
const reason = interaction.options.getString('reason', true);
Expand Down
53 changes: 53 additions & 0 deletions src/commands/slash/Staff/leave.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
ApplicationCommandOptionType,
ChatInputCommandInteraction,
Guild,
RESTPostAPIChatInputApplicationCommandsJSONBody,
} from 'discord.js';
import SuperClient from '../../../core/Client.js';
import BaseCommand from '../../../core/BaseCommand.js';
import { isDev } from '../../../utils/Utils.js';
import { emojis } from '../../../utils/Constants.js';
import { RemoveMethods } from '../../../typings/index.js';

export default class Respawn extends BaseCommand {
readonly staffOnly = true;
readonly data: RESTPostAPIChatInputApplicationCommandsJSONBody = {
name: 'leave',
description: 'Make me leave a server (Dev\'s toy only)',
options: [
{
type: ApplicationCommandOptionType.String,
name: 'server_id',
description: 'The ID of the server to leave.',
required: true,
},
],
};
async execute(interaction: ChatInputCommandInteraction) {
if (!isDev(interaction.user.id)) {
await interaction.reply({
content: `${emojis.dnd_anim} You are not authorized to use this command.`,
ephemeral: true,
});
return;
}

const guildId = interaction.options.getString('server_id', true);
const leftGuild = SuperClient.resolveEval(
await interaction.client.cluster.broadcastEval(
async (client, _serverId) => {
const guild = client.guilds.cache.get(_serverId);
if (!guild) return;

return await guild.leave();
},
{ guildId, context: guildId },
),
) as RemoveMethods<Guild> | undefined;

await interaction.reply(
`${emojis.tick} Successfully Left guild ${leftGuild?.name} (${leftGuild?.id})`,
);
}
}
1 change: 0 additions & 1 deletion src/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const {
export const isDevBuild = process.env.NODE_ENV === 'development';

export const PROJECT_VERSION = require('../../package.json').version ?? 'Unknown';
export const CLIENT_ID = isDevBuild ? '798748015435055134' : '769921109209907241';
export const SUPPORT_SERVER_ID = '770256165300338709';
export const VOTER_ROLE_ID = '985153241727770655';

Expand Down
4 changes: 3 additions & 1 deletion src/utils/RegisterCmdCli.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import Logger from './Logger.js';
import loadCommandFiles from './LoadCommands.js';
import { REST, Routes } from 'discord.js';
import { CLIENT_ID, SUPPORT_SERVER_ID } from './Constants.js';
import { SUPPORT_SERVER_ID } from './Constants.js';
import { commandsMap } from '../core/BaseCommand.js';
import 'dotenv/config';

const greyText = (text: unknown) => `\x1b[38;5;246m${text}\x1b[0m`;
const greenText = (text: unknown) => `\x1b[38;5;78m${text}\x1b[0m`;

const CLIENT_ID = process.env.CLIENT_ID as string;

const registerAllCommands = async (staffOnly = false) => {
// make sure CommandsMap is not empty
await loadCommandFiles();
Expand Down
Loading

0 comments on commit 824f5d9

Please sign in to comment.