Skip to content

Commit

Permalink
added V and CoffeeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
vKxni committed Nov 28, 2021
1 parent 124d3ce commit 6269bb7
Show file tree
Hide file tree
Showing 6 changed files with 312 additions and 0 deletions.
1 change: 1 addition & 0 deletions CoffeeScript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 3 additions & 0 deletions CoffeeScript/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bottoken": "token"
}
234 changes: 234 additions & 0 deletions CoffeeScript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions CoffeeScript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "coffeescript",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"eris": "^0.16.1",
"lowdb": "^3.0.0",
"node-fetch": "^3.1.0"
}
}
12 changes: 12 additions & 0 deletions CoffeeScript/src/main.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
config = require("./config.json")

Eris = require("eris")
client = new Eris(config.token)
client.config = config

client.on 'ready', ->
console.log """
Logged as #{client.user.username}##{client.user.discriminator}
"""

client.connect()
45 changes: 45 additions & 0 deletions V/main.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import json
import os
import discordv as vd
import net.http

const (
prefix = '.'
)

fn main() {

token := os.getenv('BOT_TOKEN')
println(token)
if token == '' {
println('Please provide a valid bot token using BOT_TOKEN environment variable')
return
}

mut client := vd.new(token: token, intents: 515) ?
client.on_ready(on_ready)
client.on_message_create(on_message_create)
client.open() ?

}

fn on_ready (mut client vd.Client, evt &vd.Ready) {
println('Bot ready!')
}

fn on_message_create(mut client vd.Client, evt &vd.MessageCreate) {

if !evt.content.starts_with(prefix) {
return
}

mut arguments := evt.content.substr(1, evt.content.len).split(' ')
cmd_name := arguments[0]
arguments = arguments[1..arguments.len]


if cmd_name == '!ping' {
client.channel_message_send(evt.channel_id, content: 'pong!')
}

}

0 comments on commit 6269bb7

Please sign in to comment.