Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
add some helpful snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasptsch committed Apr 23, 2022
1 parent d2a8aec commit c773a76
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .vscode/emmet.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"Command": {
"prefix": "command",
"body": [
"import help from '@/help/version';",
"import Command from '@classes/command';",
"import { SlashCommandBuilder } from '@discordjs/builders';",
"import Discord from 'discord.js';",
"export default new Command()",
"\t.setCommandData(",
"\t\tnew SlashCommandBuilder()",
"\t\t\t.setName('version')",
"\t\t\t.setDescription('The version of the bot in use.')",
"\t)",
"\t.setHelp(help)",
"\t.setResponse(async (interaction) => {",
"\t\tinteraction.reply({",
"\t\t\tephemeral: true,",
"\t\t\tcontent: `The version of the bot is \\`${process.env.VERSION}\\`.\\nThe discord.js version is \\`${Discord.version}\\`.`,",
"\t\t});",
"\t});"
],
"description": "Creates a command"
},
"Help": {
"prefix": "help",
"body": [
"import Help from '@/classes/help';",
"",
"export default new Help('Sends the running version of Dynamica.');"
],
"description": "Creates help file"
}
}
4 changes: 4 additions & 0 deletions src/classes/dynamicaEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ type Awaitable<T> = T | PromiseLike<T>;

/** The different events that can occur in the DynamicaEventManager */
interface DynamicaEventTypes {
/** Fires when a secondary channel has been created and is ready to be joined. */
secondaryReady: [secondary: DynamicaSecondary, guildMember: GuildMember]
/** Fired when a user joins a secondary channel. */
secondaryJoined: [secondary: DynamicaSecondary, guildMember: GuildMember]
/** Fured when a user joins a primary channel. */
Expand All @@ -17,6 +19,8 @@ interface DynamicaEventTypes {
secondaryLeft: [secondary: DynamicaSecondary, guildMember: GuildMember]
/** Fired when a user leaves a primary channel. */
primaryLeft: [primary: DynamicaPrimary, guildMember: GuildMember]
/** Fired when a secondary channel needs to be refreshed. */
secondaryRefresh: [secondary: DynamicaSecondary]
}

export class DynamicaEventManager extends EventEmitter {
Expand Down
3 changes: 1 addition & 2 deletions src/commands/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import help from '@/help/version';
import Command from '@classes/command';
import { SlashCommandBuilder } from '@discordjs/builders';
import Discord from 'discord.js';

export default new Command()
.setCommandData(
new SlashCommandBuilder()
Expand All @@ -15,4 +14,4 @@ export default new Command()
ephemeral: true,
content: `The version of the bot is \`${process.env.VERSION}\`.\nThe discord.js version is \`${Discord.version}\`.`,
});
});
});
3 changes: 1 addition & 2 deletions src/help/version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import Help from '@/classes/help';

export default new Help('Sends the running version of Dynamica.');
export default new Help('Sends the running version of Dynamica.');
16 changes: 16 additions & 0 deletions src/utils/dynamicaEventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,20 @@ import { DynamicaEventManager } from "@/classes/dynamicaEvent";

const dynamicaManager = new DynamicaEventManager()

dynamicaManager.on('secondaryJoined', (secondary, guildMember) => {
console.log(`${guildMember.displayName} joined ${secondary.discord.name}`);
})
dynamicaManager.on('secondaryLeft', (secondary, guildMember) => {
console.log(`${guildMember.displayName} left ${secondary.discord.name}`);
})
dynamicaManager.on('primaryJoined', (primary, guildMember) => {
console.log(`${guildMember.displayName} joined ${primary.discord.name}`);
})
dynamicaManager.on('primaryLeft', (primary, guildMember) => {
console.log(`${guildMember.displayName} left ${primary.discord.name}`);
})
dynamicaManager.on('secondaryRefresh', (secondary) => {
console.log(`${secondary.discord.name} refreshed`);
})

export default dynamicaManager

0 comments on commit c773a76

Please sign in to comment.