3.8.6 • Published 3 years ago
@steve12341825/discord-create v3.8.6
discord-create
discord-create
is a package that helps to create a discord.js bot easily
setup
const DiscordCreate = require('@steve12341825/discord-create');
const config = require('./config.json');
const Discord = new DiscordCreate.DiscordBot({
token: config.token,
prefix: config.prefix,
commandfile: 'commands',
eventfile: 'events'
});
Discord.login();
exmaple command
const DiscordCreate = require('@steve12341825/discord-create');
module.exports = class Test extends DiscordCreate.BaseCommand {
constructor() {
super('test', 'test', [])
}
async run (client, message, args) {
message.channel.send('command working');
}
}
example event
const DiscordCreate = require('@steve12341825/discord-create');
module.exports = class Message extends DiscordCreate.BaseEvent {
constructor() {
super('message');
}
async run(client, message) {
if (message.author.bot) return;
if (!message.guild) return;
if (message.content.startsWith(client.prefix)) {
const [name, ...args] = message.content
.slice(client.prefix.length)
.trim()
.split(/\s+/);
const command = client.commands.get(name);
if (command) {
command.run(client, message, args);
}
}
}
}
example (button and embed)
const DiscordCreate = require('@steve12341825/discord-create');
module.exports = class Test extends DiscordCreate.BaseEvent {
constructor() {
super('test', 'test', []);
}
async run(client, message, args) {
const button = new DiscordCreate.MessageButton()
.setStyle('red')
.setLabel('Button')
.setID('button1');
const embed = new DiscordCreate.MessageEmbed()
.setTitle('embed')
.setDescription('This is an embed')
message.channel.send(embed, button);
}
}