make pretty, typo fix
This commit is contained in:
parent
2d4fe63b25
commit
0df858ee54
2 changed files with 9 additions and 9 deletions
|
@ -1,9 +1,9 @@
|
||||||
# Boardsource bot
|
# Boardsource bot
|
||||||
Boardsourcebot is designed to make the lives or the boardsource mods easier to help deal with repeat questions
|
Boardsourcebot is designed to make the lives or the boardsource mods easier to help deal with repeat questions
|
||||||
|
|
||||||
## Requirementss
|
## Requirements
|
||||||
1. Install Nim using [choosenim](https://github.com/dom96/choosenim) or [Nim's website](https://nim-lang.org/install.html)
|
1. Install Nim using [choosenim](https://github.com/dom96/choosenim) or [Nim's website](https://nim-lang.org/install.html)
|
||||||
2. Install Nimble from [numble](https://github.com/nim-lang/nimble)
|
2. Install Nimble from [nimble](https://github.com/nim-lang/nimble)
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
Copy `src/config.nim.example` to `src/config.nim` and add api key, as well as
|
Copy `src/config.nim.example` to `src/config.nim` and add api key, as well as
|
||||||
|
|
|
@ -3,12 +3,12 @@ import dimscord, asyncdispatch, options, strformat, strutils
|
||||||
import yaml/serialization, streams
|
import yaml/serialization, streams
|
||||||
|
|
||||||
type CommandList = object
|
type CommandList = object
|
||||||
command : string
|
command: string
|
||||||
response : string
|
response: string
|
||||||
response2 : string
|
response2: string
|
||||||
|
|
||||||
# YAML parser
|
# YAML parser
|
||||||
proc registerCommands(file: string):seq[CommandList] =
|
proc registerCommands(file: string): seq[CommandList] =
|
||||||
var commandList: seq[CommandList]
|
var commandList: seq[CommandList]
|
||||||
var s = newFileStream(file)
|
var s = newFileStream(file)
|
||||||
load(s, commandList)
|
load(s, commandList)
|
||||||
|
@ -17,10 +17,10 @@ proc registerCommands(file: string):seq[CommandList] =
|
||||||
|
|
||||||
let commands = registerCommands("commands.yaml")
|
let commands = registerCommands("commands.yaml")
|
||||||
|
|
||||||
func checkForCmd(prefix:string, commands:seq[CommandList], m:Message): seq[string] =
|
func checkForCmd(prefix: string, commands: seq[CommandList], m: Message): seq[string] =
|
||||||
for i in commands:
|
for i in commands:
|
||||||
if fmt"{prefix}{i.command}" == m.content:
|
if fmt"{prefix}{i.command}" == m.content:
|
||||||
return @[i.response, i.response2]
|
return @[i.response, i.response2]
|
||||||
return @[""]
|
return @[""]
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ proc onReady(s: Shard, r: Ready) {.event(discord).} =
|
||||||
proc messageCreate(s: Shard, m: Message) {.event(discord).} =
|
proc messageCreate(s: Shard, m: Message) {.event(discord).} =
|
||||||
let responseSeq = checkForCmd(prefix, commands, m)
|
let responseSeq = checkForCmd(prefix, commands, m)
|
||||||
if m.author.bot: return
|
if m.author.bot: return
|
||||||
if not responseSeq[0].isEmptyOrWhitespace: # Validates response to command exists
|
if not responseSeq[0].isEmptyOrWhitespace: # Validates response to command exists
|
||||||
let msg = await discord.api.sendMessage(m.channel_id, responseSeq[0])
|
let msg = await discord.api.sendMessage(m.channel_id, responseSeq[0])
|
||||||
if not responseSeq[1].isEmptyOrWhitespace:
|
if not responseSeq[1].isEmptyOrWhitespace:
|
||||||
let msg2 = await discord.api.sendMessage(m.channel_id, responseSeq[1])
|
let msg2 = await discord.api.sendMessage(m.channel_id, responseSeq[1])
|
||||||
|
|
Loading…
Add table
Reference in a new issue