initial commit
This commit is contained in:
6
Dockerfile
Normal file
6
Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FROM node:latest
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
#COPY package*.json ./
|
||||||
|
#RUN npm install
|
||||||
|
COPY $CI_PROJECT_DIR /usr/src/app
|
||||||
|
CMD [ "node", "." ]
|
||||||
83
README.md
Normal file
83
README.md
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# Project Name
|
||||||
|
> Outline a brief description of your project.
|
||||||
|
> Live demo [_here_](https://www.example.com). <!-- If you have the project hosted somewhere, include the link here. -->
|
||||||
|
https://hub.docker.com/r/developerdurp/durpot
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
* [General Info](#general-information)
|
||||||
|
* [Technologies Used](#technologies-used)
|
||||||
|
* [Features](#features)
|
||||||
|
* [Screenshots](#screenshots)
|
||||||
|
* [Setup](#setup)
|
||||||
|
* [Usage](#usage)
|
||||||
|
* [Project Status](#project-status)
|
||||||
|
* [Room for Improvement](#room-for-improvement)
|
||||||
|
* [Acknowledgements](#acknowledgements)
|
||||||
|
* [Contact](#contact)
|
||||||
|
<!-- * [License](#license) -->
|
||||||
|
|
||||||
|
|
||||||
|
## General Information
|
||||||
|
- Provide general information about your project here.
|
||||||
|
- What problem does it (intend to) solve?
|
||||||
|
- What is the purpose of your project?
|
||||||
|
- Why did you undertake it?
|
||||||
|
<!-- You don't have to answer all the questions - just the ones relevant to your project. -->
|
||||||
|
|
||||||
|
|
||||||
|
## Technologies Used
|
||||||
|
- Tech 1 - version 1.0
|
||||||
|
- Tech 2 - version 2.0
|
||||||
|
- Tech 3 - version 3.0
|
||||||
|
|
||||||
|
|
||||||
|
## Features
|
||||||
|
List the ready features here:
|
||||||
|
- Awesome feature 1
|
||||||
|
- Awesome feature 2
|
||||||
|
- Awesome feature 3
|
||||||
|
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|

|
||||||
|
<!-- If you have screenshots you'd like to share, include them here. -->
|
||||||
|
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
What are the project requirements/dependencies? Where are they listed? A requirements.txt or a Pipfile.lock file perhaps? Where is it located?
|
||||||
|
|
||||||
|
Proceed to describe how to install / setup one's local environment / get started with the project.
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
How does one go about using it?
|
||||||
|
Provide various use cases and code examples here.
|
||||||
|
|
||||||
|
`write-your-code-here`
|
||||||
|
|
||||||
|
|
||||||
|
## Project Status
|
||||||
|
Project is: _in progress_ / _complete_ / _no longer being worked on_. If you are no longer working on it, provide reasons why.
|
||||||
|
|
||||||
|
|
||||||
|
## Room for Improvement
|
||||||
|
Include areas you believe need improvement / could be improved. Also add TODOs for future development.
|
||||||
|
|
||||||
|
Room for improvement:
|
||||||
|
- Improvement to be done 1
|
||||||
|
- Improvement to be done 2
|
||||||
|
|
||||||
|
To do:
|
||||||
|
- Feature to be added 1
|
||||||
|
- Feature to be added 2
|
||||||
|
|
||||||
|
|
||||||
|
## Acknowledgements
|
||||||
|
Give credit here.
|
||||||
|
- This project was inspired by...
|
||||||
|
- This project was based on [this tutorial](https://www.example.com).
|
||||||
|
- Many thanks to...
|
||||||
|
|
||||||
|
|
||||||
|
## Contact
|
||||||
|
Created by [@klukritz] - feel free to contact me!
|
||||||
1911
package-lock.json
generated
Normal file
1911
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
19
package.json
Normal file
19
package.json
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"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
Normal file
210
src/app.js
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
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);
|
||||||
2
src/constants.js
Normal file
2
src/constants.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export const DISCORD_TOKEN = process.env.DISCORD_TOKEN
|
||||||
|
export const CHANNEL_ID = process.env.CHANNEL_ID
|
||||||
2
src/index.js
Normal file
2
src/index.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
require = require("esm")(module/*, options*/)
|
||||||
|
module.exports = require("./app.js")
|
||||||
Reference in New Issue
Block a user