Last active
August 30, 2019 20:52
-
-
Save L33t-HAXXOR/0da1f2937336b88d9d26dad0aab4f731 to your computer and use it in GitHub Desktop.
Next Time On Dragon Ball Z...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//How can this... (main.swift) | |
protocol einBotCommands { | |
var subcommands: [String: (Message) -> ()] { get } | |
func execute(data: Message) | |
} | |
func cmdHandle(data: Any) { | |
let msg = data as! Message | |
if(msg.author?.isBot ?? true) {return} | |
if(msg.channel.type == .dm) {return} | |
let einBotCmdPrefix_ES = config.cmdPrefix_ES | |
let einBotCmdPrefix_JA = config.cmdPrefix_JA | |
let messageArray = msg.content.split(separator: " ") | |
let cmd = messageArray[0] | |
let args = messageArray.prefix(1) | |
let cmdDict: [String: einBotCommands] | |
let cmdDictES: [String: einBotCommands] = [ | |
"ayuda" : HelpCommand(), | |
"aiura" : HelpCommand(), | |
"halp" : HelpCommand(), | |
] | |
let cmdDictJA: [String: einBotCommands] = [ | |
"お世話" : HelpCommand(), | |
"助けて" : HelpCommand(), | |
] | |
func cmdExec() { | |
if let command = cmdDictES[cmd.dropFirst().lowercased()] { | |
command.execute(data: msg) | |
if let subcommand = command.subcommands[messageArray[1].lowercased()] { | |
subcommand(msg) | |
} | |
else if let command = cmdDictJA[cmd.dropFirst().lowercased()] { | |
command.execute(data: msg) | |
if let subcommand = command.subcommands[messageArray[1].lowercased()] { | |
subcommand(msg) | |
} | |
else { | |
// no subcommand | |
msg.reply(with: "No hay comando así") | |
} | |
} | |
} | |
} | |
} | |
einBot.on(.messageCreate, do: cmdHandle) | |
//...Talk to this... (mySweetSweetSweetCommand.swift) | |
///////////////////////////////////////////////////// | |
///Example Command////////////////////////////////// | |
/////////////////////////////////////////////////// | |
import Foundation | |
import Sword | |
class HelpCommand: einBotCommands { | |
var subcommands: [String: (Message) -> ()] = [ | |
"ayuda": Help.main, | |
"faq": Help.faq, | |
"rpg": Help.rpg, | |
] | |
func execute(data msg: Message) { | |
} | |
} | |
class Help { | |
static func main(data msg: Message) { | |
//Embeds called for help command | |
var helpMainPageEs = Embed() | |
helpMainPageEs.addField("Comandos", value: "__**Categorias**__\nCategoria 1\nCategoria 2\nCategoria 3\netc...", isInline: true) | |
var helpMainPageJa = Embed() | |
helpMainPageJa.addField ("コマンド", value: "__**カテゴリー**__\nカテゴリー1\nカテゴリー2\nカテゴリー3\netc...", isInline: true) | |
//Help Command Message Conditions | |
switch msg.content { | |
// COMANDOS AYUDA_ES | |
case "\(einBotCmdPrefix_ES)ayuda": | |
msg.reply(with: helpMainPageEs ) | |
case "\(einBotCmdPrefix_ES)aiura": | |
msg.reply(with: helpMainPageEs ) | |
case "\(einBotCmdPrefix_ES)halp": | |
msg.reply(with: helpMainPageEs ) | |
case "\(einBotCmdPrefix_ES)ping": | |
msg.reply(with: "Pong!") | |
// COMANDOS AYUDA_JA | |
case "\(einBotCmdPrefix_JA)お世話": | |
msg.reply(with: helpMainPageJa) | |
case "\(einBotCmdPrefix_JA)助けて": | |
msg.reply(with: helpMainPageJa) | |
case "\(einBotCmdPrefix_JA)ピング": | |
msg.reply(with: "ポング!") | |
default: | |
var uups = Embed() | |
uups.addField ("Error", value: "No hay comando así") | |
msg.reply(with: uups) | |
} | |
} | |
static func faq(data msg: Message){ | |
} | |
static func rpg(data msg: Message) { | |
} | |
static func economy(data msg: Message) { | |
} | |
static func leveling(data msg: Message) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment