This repository has been archived by the owner on Jan 4, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Update packages, create .eslint file and enforce code style #128
Open
phamleduy04
wants to merge
13
commits into
ChecksumDev:master
Choose a base branch
from
phamleduy04:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cbb384f
update packages
phamleduy04 c9eabc6
eslint
phamleduy04 53d361b
code style
phamleduy04 93cf51d
workflow
phamleduy04 168e88a
enforce code style
phamleduy04 098e769
Create .eslintignore
phamleduy04 7c2e637
Update .eslintignore
phamleduy04 8825079
update
phamleduy04 691b672
try
phamleduy04 690bb3c
fix
phamleduy04 898184f
Update eslint.yml
phamleduy04 5a62138
trigger
phamleduy04 362ae76
forget it
phamleduy04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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