Skip to content

Commit

Permalink
Remove forced converts
Browse files Browse the repository at this point in the history
  • Loading branch information
xsduan committed Jan 13, 2018
1 parent 0637c21 commit 6d87044
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ function command (message) {
if (command !== null) {
command = command[1]

const forceX2i = function (type) {
return x2iSend(message.channel,
x2i.force(type, '[', message.content.split(' ').slice(1).join(' '), ']'))
}

switch (command) {
// ping command is special case response.
case 'ping':
Expand All @@ -82,14 +77,6 @@ function command (message) {
case 'help':
promise = help.help(message.channel, bot.user)
break
case 'xsampa':
promise = forceX2i('x')
break
case 'zsampa':
promise = forceX2i('z')
break
case 'apie':
promise = forceX2i('p')
}

logMessage('processed:command/' + command)
Expand All @@ -111,22 +98,13 @@ function ping (message) {
.catch(err => logMessage('error:command/ping', err))
}

/**
* Links x2i.grab(String) to a message channel.
* @param {Message} message Message to look for an x2i string in
* @returns {(Promise<(Message|Array<Message>)>)|null} Whatever message needs handling
*/
function x2iExec (message) {
return x2iSend(message.channel, x2i.grab(message.content))
}

/**
* Sends an x2i string (but also could be used for simple embeds)
* @param {Channel} channel Channel to send message to
* @param {String} results String to put in description (body text)
* @param {Message} message Message to reply to
* @returns {(Promise<(Message|Array<Message>)>)|null} Whatever message needs handling
*/
function x2iSend (channel, results) {
function x2iExec (message) {
var results = x2i.grab(message.content)
if (results !== undefined && results.length !== 0) {
var response = new Discord.RichEmbed()
.setColor(cfg.get('embeds.colors.success'))
Expand All @@ -146,7 +124,7 @@ function x2iSend (channel, results) {
response.setDescription(results)

logMessage('processed:x2i/' + logCode)
return embed.send(channel, response)
return embed.send(message.channel, response)
} else {
logMessage('ignored:x2i')
return null
Expand All @@ -166,9 +144,7 @@ bot.on('ready', () => {
.then(() => console.log('Set game status.'))
.catch(err => console.log('Game couldn\'t be set. ' + err))
}
})

bot.on('message', message => {
}).on('message', message => {
logMessage('-start ' + message.createdTimestamp + '-')
if (!message.author.bot) {
parse(message)
Expand Down

0 comments on commit 6d87044

Please sign in to comment.