Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Update packages, create .eslint file and enforce code style #128

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/**
42 changes: 42 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = {
"env": {
"es2020": true,
"node": true,
},
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module",
},
"rules": {
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
"dot-location": ["error", "property"],
"handle-callback-err": "off",
"max-nested-callbacks": ["error", { "max": 4 }],
"max-statements-per-line": ["error", { "max": 2 }],
"no-console": "off",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-lonely-if": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
"no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
"no-trailing-spaces": ["error"],
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
"space-before-blocks": "error",
"space-before-function-paren": ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always",
}],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"yoda": "error",
"semi": "error",
},
};
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ lib-cov
# Coverage directory used by tools like istanbul
coverage

# eslint
.eslintrc.js

# nyc test coverage
.nyc_output

Expand Down
35 changes: 16 additions & 19 deletions commands/fun/cat.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,54 @@
/* eslint-disable no-undef */
require("dotenv").config();
const commando = require("discord.js-commando");
const Discord = require("discord.js");
const { Command } = require("discord.js-commando");
const { MessageEmbed } = require("discord.js");
const querystring = require("query-string");
const r2 = require("r2");
const CAT_API_URL = "https://api.thecatapi.com/";
const CAT_API_KEY = process.env.CAT_API_KEY;

module.exports = class CatCommand extends commando.Command {
module.exports = class CatCommand extends Command {
constructor(client) {
super(client, {
name: "cat",
group: "fun",
memberName: "cat",
description: "Meow."
description: "Meow.",
});
}

async run(message) {
if (message.author.bot) return;
try {
var images = await this.loadImage(message.author.username);
var image = images[0];
let embed = new Discord.MessageEmbed()
const images = await this.loadImage(message.author.username);
const image = images[0];
const embed = new MessageEmbed()
.setTitle("A picture of a cute kitty cat!")
.setImage(`${image.url}`)
.setColor("GREEN")
.setColor("GREEN");
message.channel.send(embed);
} catch (error) {
console.log(error);
}
}

async loadImage(sub_id) {
var headers = {
"X-API-KEY": CAT_API_KEY
const headers = {
"X-API-KEY": CAT_API_KEY,
};
var query_params = {
//'has_breeds':true,
const query_params = {
// 'has_breeds':true,
mime_types: "jpg,png",
size: "med",
sub_id: sub_id,
limit: 1
limit: 1,
};

let queryString = querystring.stringify(query_params);
const queryString = querystring.stringify(query_params);

try {
let _url = CAT_API_URL + `v1/images/search?${queryString}`;
var response = await r2.get(_url, { headers }).json;
const _url = CAT_API_URL + `v1/images/search?${queryString}`;
return await r2.get(_url, { headers }).json;
} catch (e) {
console.log(e);
}
return response;
}
};
26 changes: 12 additions & 14 deletions commands/fun/dog.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,45 @@ module.exports = class DogCommand extends commando.Command {
name: "dog",
group: "fun",
memberName: "dog",
description: "Woof."
description: "Woof.",
});
}

async run(message) {
if (message.author.bot) return;
try {
var images = await this.loadImage(message.author.username);
const images = await this.loadImage(message.author.username);

var image = images[0];
const image = images[0];

let embed = new Discord.MessageEmbed()
const embed = new Discord.MessageEmbed()
.setTitle("A picture of a cute puppy!")
.setImage(`${image.url}`)
.setColor("GREEN")
.setColor("GREEN");
message.channel.send(embed);
} catch (error) {
console.log(error);
}
}

async loadImage(sub_id) {
var headers = {
"X-API-KEY": DOG_API_KEY
const headers = {
"X-API-KEY": DOG_API_KEY,
};
var query_params = {
const query_params = {
has_breeds: true,
mime_types: "jpg,png",
size: "small",
sub_id: sub_id,
limit: 1
limit: 1,
};

let queryString = querystring.stringify(query_params);
const queryString = querystring.stringify(query_params);

try {
let _url = DOG_API_URL + `v1/images/search?${queryString}`;
var response = await r2.get(_url, { headers }).json;
const _url = DOG_API_URL + `v1/images/search?${queryString}`;
return await r2.get(_url, { headers }).json;
} catch (e) {
console.log(e);
}
return response;
}
};
9 changes: 4 additions & 5 deletions commands/fun/hug.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
require("dotenv").config();
const commando = require("discord.js-commando");
const oneLine = require("common-tags").oneLine;
const Discord = require("discord.js");
const Tenor = require("tenorjs").client({
Key: process.env.TENORAPI, // https://tenor.com/developer/keyregistration
Filter: "off", // "off", "low", "medium", "high", not case sensitive
Locale: "en_US", // Your locale here, case-sensitivity depends on input
MediaFilter: "minimal", // either minimal or basic, not case sensitive
DateFormat: "D/MM/YYYY - H:mm:ss A" // Change this accordingly
DateFormat: "D/MM/YYYY - H:mm:ss A", // Change this accordingly
});

module.exports = class HugCommand extends commando.Command {
Expand All @@ -24,8 +23,8 @@ module.exports = class HugCommand extends commando.Command {
examples: ["hug @Wumpus#0000"],
throttling: {
usages: 2,
duration: 10
}
duration: 10,
},
});
}

Expand All @@ -35,7 +34,7 @@ module.exports = class HugCommand extends commando.Command {
.then(Results => {
Results.forEach(Post => {
msg.channel.send(
user.tag + " Was furiousley hugged by " + msg.author.tag
user.tag + " Was furiousley hugged by " + msg.author.tag,
);
msg.channel.send(`${Post.url}`);
});
Expand Down
3 changes: 1 addition & 2 deletions commands/fun/joke.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ module.exports = class JokeCommand extends commando.Command {
name: "joke",
group: "fun",
memberName: "joke",
description: "Gives you a funny dad joke"
description: "Gives you a funny dad joke",
});
}

async run(message) {
if (message.author.bot) return;
const dadjoke = await joke.randomJoke();
message.reply(dadjoke);
}
Expand Down
18 changes: 8 additions & 10 deletions commands/misc/credits.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const commando = require('discord.js-commando');
const { Command } = require('discord.js-commando');
const oneLine = require('common-tags').oneLine;

module.exports = class CreditsCommand extends commando.Command {
const { MessageEmbed } = require('discord.js');
module.exports = class CreditsCommand extends Command {
constructor(client) {
super(client, {
name: 'credits',
Expand All @@ -12,17 +12,15 @@ module.exports = class CreditsCommand extends commando.Command {
Displays bot Developer(s) and such.
`,
examples: ['credits'],
})
});
}

async run(msg) {
if (msg.author.bot) return;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont really need this because default discord.js commando auto ignore bot messages

let { MessageEmbed } = require('discord.js')
let embed = new MessageEmbed()
const embed = new MessageEmbed()
.setTitle("Bot Credits")
.setDescription("Blizzard is created by CollierDevs#2407")
.setFooter("Blizzard is made with 💖 and ☕")
.setColor("AQUA")
msg.channel.send(embed)
.setColor("AQUA");
msg.channel.send(embed);
}
}
};
35 changes: 16 additions & 19 deletions commands/misc/hastebin.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const commando = require("discord.js-commando");
const { Command } = require("discord.js-commando");
const oneLine = require("common-tags").oneLine;
const { MessageEmbed } = require("discord.js");
const hastebin = require("hastebin-gen");

module.exports = class HastebinCommand extends commando.Command {
module.exports = class HastebinCommand extends Command {
constructor(client) {
super(client, {
name: "haste",
Expand All @@ -19,27 +19,24 @@ module.exports = class HastebinCommand extends commando.Command {
{
key: "haste",
prompt: "What text would you to post on hastebin?",
type: "string"
}
]
type: "string",
},
],
});
}

async run(message, args) {
if (message.author.bot) return;
hastebin(args.haste)
.then(result => {
let embed = new MessageEmbed()
.setAuthor(
"Posted to Hastebin",
"https://dl1.cbsistatic.com/i/2018/12/06/ba48919c-d69b-47de-bdda-e571a5d0cb68/95f55392ccf92166fe42d1fb483992f6/imgingest-3562709916302622107.png"
)
.setDescription(result)
.setColor("DARK_BLUE");
message.channel.send(embed)
})
.catch(err => {
console.error(err);
});
const result = await hastebin(args.haste).catch(err => {
console.error(err);
});
const embed = new MessageEmbed()
.setAuthor(
"Posted to Hastebin",
"https://dl1.cbsistatic.com/i/2018/12/06/ba48919c-d69b-47de-bdda-e571a5d0cb68/95f55392ccf92166fe42d1fb483992f6/imgingest-3562709916302622107.png",
)
.setDescription(result)
.setColor("DARK_BLUE");
message.channel.send(embed);
}
};
19 changes: 9 additions & 10 deletions commands/misc/suggest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const commando = require('discord.js-commando');
const { Command } = require('discord.js-commando');
const oneLine = require('common-tags').oneLine;
const { MessageEmbed } = require('discord.js')
const { MessageEmbed } = require('discord.js');

module.exports = class SuggestCommand extends commando.Command {
module.exports = class SuggestCommand extends Command {
constructor(client) {
super(client, {
name: 'suggest',
Expand All @@ -24,17 +24,16 @@ module.exports = class SuggestCommand extends commando.Command {
type: 'string',
},
],
})
});
}

async run(msg, args) {
if (msg.author.bot) return;
msg.reply("Thank you for your suggestion, I have sent it over to my Developers!")
let suggestion = new MessageEmbed()
msg.reply("Thank you for your suggestion, I have sent it over to my Developers!");
const suggestion = new MessageEmbed()
.setAuthor(`Suggestion from ${msg.author.tag} | ${msg.author.id}`, msg.author.displayAvatarURL)
.addField("Suggestion", args.suggestion)
.setColor("AQUA")
.setTimestamp()
this.client.channels.get('637457372603875328').send(suggestion)
.setTimestamp();
this.client.channels.get('637457372603875328').send(suggestion);
}
}
};
Loading