2.3.0 • Published 6 months ago

@hammerhq/plugin-commands v2.3.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
6 months ago

📦 Installation

$ npm install @hammerhq/plugin-commands

🚀 Usage

import { bootstrap } from "@hammerhq/core";
import { CommandsPlugin } from "@hammerhq/plugin-commands";
import { Client } from "discord.js";
import { join } from "path";

// create your own commands or download them via npm!
import { MyCommand } from "./commands/MyCommand";

const client = new Client(ClientOptions);

async function main() {
	await bootstrap({
		client,
		i18n: {
			defaultLocale: "en", // default locale, see @hammerhq/localization
			directory: join(__dirname, "..", "locales"), // locales directory, see @hammerhq/localization
		},
		plugins: [
			// hammer plugins here. You can download them with hammer cli, from npm and create your own!
			CommandsPlugin.forRoot({
				token: CONFIG.BOT_TOKEN,
				clientId: CONFIG.CLIENT_ID,
				commands: [MyCommand], // commands to register
			}),
		],
	});

	await client.login(CONFIG.BOT_TOKEN);
}

main();

🧩 Creating a command

import { Client } from "@hammerhq/core";
import { Command } from "@hammerhq/plugin-commands";
import {
	ChatInputCommandInteraction,
	Client as DJSClient,
	SlashCommandBuilder,
} from "discord.js";

@Command({
	meta: new SlashCommandBuilder()
		.setName("ping")
		.setDescription("Replies with Pong!"),
})
export class PingCommand {
	@Client()
	client!: DJSClient;

	public async execute(interaction: ChatInputCommandInteraction) {
		interaction.reply({
			content: `:ping_pong: Pong! \`${this.client.ws.ping}ms\``,
		});
	}
}

🧦 Looking For Contributors

We are looking for contributors to actively work on Hammer and to contribute to the repos. There is still lots of work to do. If you are interested in contributing, please join our Discord server. (There will be a surprise for early contributors!)

🔑 License

Copyright © 2022 Barış DEMİRCİ.

Distributed under the GPL-3.0 License. See LICENSE for more information.

🧦 Contributing

This repo is open for #hacktoberfest. Feel free to use GitHub's features.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/my-feature)
  3. Run prettier (npm run format)
  4. Commit your Changes (git commit -m 'my awesome feature my-feature')
  5. Push to the Branch (git push origin feature/my-feature)
  6. Open a Pull Request

⭐️ Show your support

Give a ⭐️ if this project helped you!

☎️ Contact