@@ -1,11 +0,0 @@
|
|||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
charset = utf-8
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
insert_final_newline = true
|
|
||||||
|
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
.env
|
.env
|
||||||
node_modules
|
node_modules
|
||||||
|
__debug_bin.exe
|
||||||
|
|||||||
23
Dockerfile
23
Dockerfile
@@ -1,7 +1,18 @@
|
|||||||
FROM node:latest
|
FROM golang:latest
|
||||||
WORKDIR /usr/src/app
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN npm install
|
|
||||||
COPY . /usr/src/app
|
|
||||||
CMD [ "node", "." ]
|
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the source code into the container
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the Go binary
|
||||||
|
RUN go build -o bot
|
||||||
|
|
||||||
|
# Set the DISCORD_BOT_TOKEN environment variable
|
||||||
|
ENV TOKEN=${DISCORD_TOKEN}
|
||||||
|
ENV BOTPREFIX="!"
|
||||||
|
ENV ChannelID=${ChannelID}
|
||||||
|
|
||||||
|
# Run the bot binary
|
||||||
|
CMD ["./bot"]
|
||||||
13
go.mod
Normal file
13
go.mod
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module golang-discord-bot
|
||||||
|
|
||||||
|
go 1.19
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/bwmarrin/discordgo v0.26.1 // indirect
|
||||||
|
github.com/gorilla/websocket v1.4.2 // indirect
|
||||||
|
github.com/joho/godotenv v1.4.0 // indirect
|
||||||
|
github.com/sashabaranov/go-openai v1.5.7 // indirect
|
||||||
|
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
|
||||||
|
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326 // indirect
|
||||||
|
golang.org/x/sys v0.1.0 // indirect
|
||||||
|
)
|
||||||
20
go.sum
Normal file
20
go.sum
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
github.com/bwmarrin/discordgo v0.26.1 h1:AIrM+g3cl+iYBr4yBxCBp9tD9jR3K7upEjl0d89FRkE=
|
||||||
|
github.com/bwmarrin/discordgo v0.26.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
|
||||||
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
|
||||||
|
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
|
github.com/sashabaranov/go-openai v1.5.7 h1:8DGgRG+P7yWixte5j720y6yiXgY3Hlgcd0gcpHdltfo=
|
||||||
|
github.com/sashabaranov/go-openai v1.5.7/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
|
||||||
|
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg=
|
||||||
|
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
|
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326 h1:QfTh0HpN6hlw6D3vu8DAwC8pBIwikq0AI1evdm+FksE=
|
||||||
|
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
|
||||||
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
292
main.go
Normal file
292
main.go
Normal file
@@ -0,0 +1,292 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
openai "github.com/sashabaranov/go-openai"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Token string
|
||||||
|
BotPrefix string
|
||||||
|
ChannelID string
|
||||||
|
BotId string
|
||||||
|
apiKey string
|
||||||
|
goBot *discordgo.Session
|
||||||
|
|
||||||
|
config *configStruct
|
||||||
|
)
|
||||||
|
|
||||||
|
type configStruct struct {
|
||||||
|
Token string `json : "Token"`
|
||||||
|
BotPrefix string `json : "BotPrefix"`
|
||||||
|
ChannelID string `json : "ChannelID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type jingleBellsResponse struct {
|
||||||
|
Message string `json:"message"`
|
||||||
|
Subtitle string `json:"subtitle"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type dadJokeResponse struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Joke string `json:"joke"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type yomamaJokeResponse struct {
|
||||||
|
Joke string `json:"joke"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReadConfig() error {
|
||||||
|
|
||||||
|
err := godotenv.Load(".env")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
Token = os.Getenv("TOKEN")
|
||||||
|
BotPrefix = os.Getenv("BOTPREFIX")
|
||||||
|
ChannelID = os.Getenv("ChannelID")
|
||||||
|
apiKey = os.Getenv("OPENAI_API_KEY")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Start() {
|
||||||
|
goBot, err := discordgo.New("Bot " + Token)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err := goBot.User("@me")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
BotId = u.ID
|
||||||
|
|
||||||
|
goBot.AddHandler(messageHandler)
|
||||||
|
goBot.AddHandler(handleGuildMemberAdd)
|
||||||
|
goBot.AddHandler(handleGuildMemberRemove)
|
||||||
|
goBot.AddHandler(handleTag)
|
||||||
|
|
||||||
|
err = goBot.Open()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println("Bot is running!")
|
||||||
|
}
|
||||||
|
|
||||||
|
func messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
|
if m.Author.ID == BotId {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
baseurl := "https://kong.durp.info/"
|
||||||
|
switch m.Content {
|
||||||
|
case BotPrefix + "ping":
|
||||||
|
s.ChannelMessageSend(m.ChannelID, "pong")
|
||||||
|
//case BotPrefix + "meme":
|
||||||
|
// response = getJson(baseurl+"random-meme", "url")
|
||||||
|
// s.ChannelMessageSend(m.ChannelID, response)
|
||||||
|
//case BotPrefix + "catfact":
|
||||||
|
// response = getJson(baseurl+"cat-facts/fact", "fact")
|
||||||
|
// s.ChannelMessageSend(m.ChannelID, response)
|
||||||
|
//case BotPrefix + "cat":
|
||||||
|
// response = getJson(baseurl+"random-cats", "file")
|
||||||
|
// s.ChannelMessageSend(m.ChannelID, response)
|
||||||
|
case BotPrefix + "yomama":
|
||||||
|
sendAPIRequest(s, m, baseurl, "yomama")
|
||||||
|
case BotPrefix + "dadjoke":
|
||||||
|
sendAPIRequest(s, m, baseurl, "dadjoke")
|
||||||
|
//case BotPrefix + "dog":
|
||||||
|
// response = getJson(baseurl+"random-dogs", "message")
|
||||||
|
// s.ChannelMessageSend(m.ChannelID, response)
|
||||||
|
case BotPrefix + "jinglebells":
|
||||||
|
sendAPIRequest(s, m, baseurl, "jinglebells")
|
||||||
|
case BotPrefix + "swanson":
|
||||||
|
sendAPIRequest(s, m, baseurl, "swanson")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
err := ReadConfig()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Start()
|
||||||
|
|
||||||
|
<-make(chan struct{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getSwansonQuote(s *discordgo.Session, m *discordgo.MessageCreate, url string) {
|
||||||
|
resp, err := http.Get(url + "/ronswanson")
|
||||||
|
if err != nil {
|
||||||
|
errStr := err.Error()
|
||||||
|
s.ChannelMessageSend(m.ChannelID, errStr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
var data []string
|
||||||
|
err = json.NewDecoder(resp.Body).Decode(&data)
|
||||||
|
if err != nil {
|
||||||
|
errStr := err.Error()
|
||||||
|
s.ChannelMessageSend(m.ChannelID, errStr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(data) == 0 {
|
||||||
|
errStr := "No quotes found."
|
||||||
|
s.ChannelMessageSend(m.ChannelID, errStr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
s.ChannelMessageSend(m.ChannelID, data[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendAPIRequest(s *discordgo.Session, m *discordgo.MessageCreate, url string, endpoint string) {
|
||||||
|
var response interface{}
|
||||||
|
switch endpoint {
|
||||||
|
case "dadjoke":
|
||||||
|
url = url + "/dadjoke"
|
||||||
|
var data dadJokeResponse
|
||||||
|
response = &data
|
||||||
|
case "jinglebells":
|
||||||
|
url = url + "/foaas/jinglebells/durp"
|
||||||
|
var data jingleBellsResponse
|
||||||
|
response = &data
|
||||||
|
case "yomama":
|
||||||
|
url = url + "/yomama"
|
||||||
|
var data yomamaJokeResponse
|
||||||
|
response = &data
|
||||||
|
case "swanson":
|
||||||
|
getSwansonQuote(s, m, url)
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
s.ChannelMessageSend(m.ChannelID, "Invalid endpoint.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
errStr := err.Error()
|
||||||
|
s.ChannelMessageSend(m.ChannelID, errStr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", "application/json")
|
||||||
|
|
||||||
|
client := http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
errStr := err.Error()
|
||||||
|
s.ChannelMessageSend(m.ChannelID, errStr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
err = json.NewDecoder(resp.Body).Decode(response)
|
||||||
|
if err != nil {
|
||||||
|
errStr := err.Error()
|
||||||
|
s.ChannelMessageSend(m.ChannelID, errStr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch endpoint {
|
||||||
|
case "dadjoke":
|
||||||
|
data := response.(*dadJokeResponse)
|
||||||
|
s.ChannelMessageSend(m.ChannelID, data.Joke)
|
||||||
|
case "jinglebells":
|
||||||
|
data := response.(*jingleBellsResponse)
|
||||||
|
s.ChannelMessageSend(m.ChannelID, data.Message)
|
||||||
|
case "yomama":
|
||||||
|
data := response.(*yomamaJokeResponse)
|
||||||
|
s.ChannelMessageSend(m.ChannelID, data.Joke)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleGuildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) {
|
||||||
|
message := fmt.Sprintf("Welcome <@%s> to our server!", m.Member.User.ID)
|
||||||
|
_, err := s.ChannelMessageSend(ChannelID, message)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error sending welcome message: %v\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleGuildMemberRemove(s *discordgo.Session, m *discordgo.GuildMemberRemove) {
|
||||||
|
|
||||||
|
message := fmt.Sprintf("Goodbye %s", m.Member.User.Username)
|
||||||
|
_, err := s.ChannelMessageSend(ChannelID, message)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error sending goodbye message: %v\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleTag(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
|
// Ignore messages sent by the bot itself
|
||||||
|
if m.Author.ID == s.State.User.ID {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
client := openai.NewClient(apiKey)
|
||||||
|
|
||||||
|
// Check if bot is mentioned in message
|
||||||
|
for _, mention := range m.Mentions {
|
||||||
|
if mention.ID == s.State.User.ID {
|
||||||
|
// Remove mention from message content
|
||||||
|
content := strings.Replace(m.ContentWithMentionsReplaced(), "<@"+s.State.User.ID+">", "", -1)
|
||||||
|
content = strings.Replace(content, "<@!"+s.State.User.ID+">", "", -1)
|
||||||
|
content = strings.TrimSpace(content)
|
||||||
|
|
||||||
|
resp, err := client.CreateChatCompletion(
|
||||||
|
context.Background(),
|
||||||
|
openai.ChatCompletionRequest{
|
||||||
|
Model: openai.GPT3Dot5Turbo,
|
||||||
|
Messages: []openai.ChatCompletionMessage{
|
||||||
|
{
|
||||||
|
Role: openai.ChatMessageRoleUser,
|
||||||
|
Content: content,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("ChatCompletion error: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(resp.Choices[0].Message.Content)
|
||||||
|
|
||||||
|
// Send generated response back to Discord
|
||||||
|
_, err = s.ChannelMessageSend(m.ChannelID, resp.Choices[0].Message.Content)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1911
package-lock.json
generated
1911
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "durpot",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "src",
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"@discordjs/opus": "^0.5.3",
|
|
||||||
"discord.js": "^12.5.3",
|
|
||||||
"dotenv": "^10.0.0",
|
|
||||||
"esm": "^3.2.25",
|
|
||||||
"node-fetch": "^2.6.1",
|
|
||||||
"request": "^2.88.2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
210
src/app.js
210
src/app.js
@@ -1,210 +0,0 @@
|
|||||||
const Discord = require('discord.js');
|
|
||||||
const { Client, MessageAttachment, MessageEmbed } = require('discord.js');
|
|
||||||
const fetch = require('node-fetch');
|
|
||||||
const querystring = require('querystring');
|
|
||||||
const request = require('request');
|
|
||||||
require('dotenv').config()
|
|
||||||
|
|
||||||
const client = new Client();
|
|
||||||
const prefix = '!';
|
|
||||||
|
|
||||||
const trim = (str, max) => (str.length > max ? `${str.slice(0, max - 3)}...` : str);
|
|
||||||
|
|
||||||
import { DISCORD_TOKEN, CHANNEL_ID } from './constants'
|
|
||||||
|
|
||||||
client.on('ready', () => {
|
|
||||||
console.log(`Logged in as ${client.user.tag}!`);
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on("guildMemberAdd", (member) => {
|
|
||||||
// console.log(member);
|
|
||||||
const channelId = "775100831590252557";
|
|
||||||
|
|
||||||
const message = `Welcome <@${
|
|
||||||
member.id
|
|
||||||
}> to our server!`;
|
|
||||||
|
|
||||||
const channel = member.guild.channels.cache.get(channelId);
|
|
||||||
channel.send(message);
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('guildMemberRemove', member => {
|
|
||||||
const channelId = "775100831590252557";
|
|
||||||
|
|
||||||
const message = `Goodbye ${
|
|
||||||
member.user.username
|
|
||||||
}`;
|
|
||||||
|
|
||||||
const channel = member.guild.channels.cache.get(channelId);
|
|
||||||
channel.send(message);
|
|
||||||
})
|
|
||||||
|
|
||||||
client.on('message', async message => {
|
|
||||||
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
|
||||||
|
|
||||||
const args = message.content.slice(prefix.length).trim().split(/ +/);
|
|
||||||
const command = args.shift().toLowerCase();
|
|
||||||
|
|
||||||
if (command === 'commands') {
|
|
||||||
message.channel.send('\
|
|
||||||
I know the follwing commands\n\
|
|
||||||
!cat\n\
|
|
||||||
!urban <Search term>\n\
|
|
||||||
!catfact\n\
|
|
||||||
!meme\n\
|
|
||||||
!yomama\n\
|
|
||||||
!dadjoke\n\
|
|
||||||
!dog\n\
|
|
||||||
!geekjoke\n\
|
|
||||||
!swanson\n\
|
|
||||||
');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'cat') {
|
|
||||||
const { file } = await fetch('https://kong.durp.info/random-cats').then(response => response.json());
|
|
||||||
|
|
||||||
message.channel.send(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'urban') {
|
|
||||||
if (!args.length) {
|
|
||||||
return message.channel.send('You need to supply a search term!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = querystring.stringify({ term: args.join(' ') });
|
|
||||||
|
|
||||||
const { list } = await fetch(`https://kong.durp.info/urban-dictionary/v0/define?${query}`).then(response => response.json());
|
|
||||||
|
|
||||||
if (!list.length) {
|
|
||||||
return message.channel.send(`No results found for **${args.join(' ')}**.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [answer] = list;
|
|
||||||
|
|
||||||
const embed = new Discord.MessageEmbed()
|
|
||||||
.setColor('#EFFF00')
|
|
||||||
.setTitle(answer.word)
|
|
||||||
.setURL(answer.permalink)
|
|
||||||
.addFields(
|
|
||||||
{ name: 'Definition', value: trim(answer.definition, 1024) },
|
|
||||||
{ name: 'Example', value: trim(answer.example, 1024) },
|
|
||||||
{ name: 'Rating', value: `${answer.thumbs_up} thumbs up. ${answer.thumbs_down} thumbs down.` },
|
|
||||||
);
|
|
||||||
message.channel.send(embed);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'catfact') {
|
|
||||||
|
|
||||||
request({
|
|
||||||
url:"https://kong.durp.info/cat-facts/fact",
|
|
||||||
json: true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body.fact);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'meme') {
|
|
||||||
request({
|
|
||||||
url:"https://kong.durp.info/random-meme",
|
|
||||||
json: true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body.url);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'yomama') {
|
|
||||||
request({
|
|
||||||
url:"https://kong.durp.info/yomama",
|
|
||||||
json: true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body.joke);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'dadjoke') {
|
|
||||||
request({
|
|
||||||
url:"https://kong.durp.info/dadjoke",
|
|
||||||
json:true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body.joke);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'dog') {
|
|
||||||
request({
|
|
||||||
url:"https://kong.durp.info/random-dogs",
|
|
||||||
json: true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body.message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'geekjoke') {
|
|
||||||
request({
|
|
||||||
url:"https://kong.durp.info/geekjoke",
|
|
||||||
json:true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'swanson') {
|
|
||||||
request({
|
|
||||||
url:"https://kong.durp.info/ronswanson",
|
|
||||||
json:true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'jinglebells') {
|
|
||||||
|
|
||||||
request({
|
|
||||||
url:"https://kong.durp.info/foaas/jinglebells/durp",
|
|
||||||
json:true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body.message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'nugget') {
|
|
||||||
|
|
||||||
if (!args.length) {
|
|
||||||
return message.channel.send('You need to supply a search term!');
|
|
||||||
}
|
|
||||||
|
|
||||||
request({
|
|
||||||
url:'https://kong.durp.info/foaas/nugget/' + args + '/durp',
|
|
||||||
json:true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body.message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'rockstar') {
|
|
||||||
|
|
||||||
if (!args.length) {
|
|
||||||
return message.channel.send('You need to supply a search term!');
|
|
||||||
}
|
|
||||||
|
|
||||||
request({
|
|
||||||
url:'https://kong.durp.info/foaas/rockstar/' + args + '/durp',
|
|
||||||
json:true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body.message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command === 'because') {
|
|
||||||
|
|
||||||
request({
|
|
||||||
url:"https://kong.durp.info/foaas/because/durp",
|
|
||||||
json:true
|
|
||||||
}, (err, response, body) => {
|
|
||||||
message.channel.send(body.message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
client.login(DISCORD_TOKEN);
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
export const DISCORD_TOKEN = process.env.DISCORD_TOKEN
|
|
||||||
export const CHANNEL_ID = process.env.CHANNEL_ID
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
require = require("esm")(module/*, options*/)
|
|
||||||
module.exports = require("./app.js")
|
|
||||||
Reference in New Issue
Block a user