This is a simple article showing multiple examples of how you can use Corebot's addon system. These examples are supposed to be very basic. Nothing complex will be in this guide.
Please note that this guide is out of date and will be updated soon!
This addon adds a simple command that responds with π Ping!
or π Pong!
when a user runs -pong
or -ping
.
const Utils = require('../modules/utils')
const CommandHandler = require('../modules/handlers/CommandHandler')
const Embed = Utils.Embed;
module.exports = async bot => {
CommandHandler.set({
name: "ping",
run: async (bot, message, args, { prefixUsed, commandUsed }) => {
if (commandUsed == "ping") message.channel.send(Embed({ title: "π Pong!"}))
else message.channel.send(Embed({ title: "π Ping!"}))
},
description: "Pong!",
usage: "ping",
aliases: ["pong"],
type: "other"
})
}
Notes:
This addon adds a simple command that responds with π Hello!
when someone runs the -hey
or -hi
.
const Utils = require('../modules/utils')
const CommandHandler = require('../modules/handlers/CommandHandler')
const Embed = Utils.Embed;
module.exports = async bot => {
CommandHandler.set({
name: "hey",
run: async (bot, message, args, { prefixUsed, commandUsed }) => {
message.channel.send("π Hello!")
},
description: "Hey!",
usage: "hey",
aliases: [ "hi" ],
type: "general"
})
}
This addon uses Corebot's event handler and the guildMemberAdd event to inform users to welcome new members that join the server.
const Utils = require('../modules/utils')
const EventHandler = require('../modules/handlers/EventHandler')
module.exports = async bot => {
EventHandler.set('guildMemberAdd', (bot, member) => {
let channel = Utils.findChannel('main-chat', member.guild);
if (channel) channel.send(`π A new person just joined the server. Everyone say welcome to ${member}!`)
})
}
This addon will remind users about your Minecraft server on start up and every 10 minutes.
const Utils = require('../modules/utils')
module.exports = async bot => {
function reminder() {
let channel = Utils.findChannel('main', bot.guilds.cache.first())
if (channel) channel.send("Hey everyone! Our Minecraft server's IP is **play.example.com**. Feel free to join if you want!")
}
reminder()
setInterval(reminder, 10 * 60 * 1000)
}