Skip to content

Commit

Permalink
v1.3.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatsLiamS committed Jun 3, 2021
1 parent d453f2b commit 7eb5dd3
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 44 deletions.
8 changes: 8 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Overview

**Provide a general overview of this PR:**

## General Information
1. **Does it solve a bug?**
2. **What changes have you made?**
3. **What alternatives have you tried?**
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '39 10 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules/

.git/
.git/

test/
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ node_modules/
.git/

.github/
.gitignore
.gitignore

test/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ This package comes from the developer of verified bots: [**@Coin Flipper#1767**]
- [x] Send Messages As the Bot

### Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our [Discord Server](https://discord.gg/2je9aJynqt).
If you don't understand something in the [documentation](https://github.com/ThatsLiamS/discord.js-ghost-ping/wiki), you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our [Discord Server](https://discord.gg/2je9aJynqt).

# **Installation**
To install, do this command in your shell or command prompt then you are good to go!
```js
```
npm install discord.js-ghost-ping
/* or */
yarn add discord.js-ghost-ping
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "discord.js-ghost-ping",
"version": "1.3.2",
"version": "1.3.3",
"description": "Detect Ghost Pings inside of discord.js!",
"main": "src/index.js",
"scripts": {
"run": "node src/index.js"
"test": "node test/index.js"
},
"keywords": [
"JavaScript",
Expand Down
22 changes: 19 additions & 3 deletions src/features/ghostping.js → src/features/detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ async function messageDelete(message, value){

let stringMentions = "";


await message.mentions.members.forEach(member => {
if(!member.user.bot && member.id != message.author.id){
stringMentions += `${member} `
Expand Down Expand Up @@ -73,7 +72,24 @@ async function messageUpdate(oldMessage, newMessage, value){
return send(value, newMessage, stringMentions)
}


function detector(EventType, ...args){

if(EventType){
if(EventType == 'messageDelete'){
return messageDelete(...args)
}
if(EventType == 'messageUpdate'){
return messageUpdate(...args)
}

throw ErrorMessages.unexpectedParameterError

}
else{
throw ErrorMessages.expectedParameterError
}
}
module.exports = {
messageDelete,
messageUpdate
detector
}
22 changes: 2 additions & 20 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
const { messageDelete, messageUpdate } = require(`${__dirname}/features/ghostping`)
const { ErrorMessages } = require(`${__dirname}/util/errors`)

function detector(EventType, ...args){

if(EventType){
if(EventType == 'messageDelete'){
return messageDelete(...args)
}
if(EventType == 'messageUpdate'){
return messageUpdate(...args)
}

throw ErrorMessages.unexpectedParameterError

} else{
throw ErrorMessages.expectedParameterError
}
}
const { detector } = require(`${__dirname}/features/detector`)

module.exports = {
detector
}
}
10 changes: 3 additions & 7 deletions src/util/embedValues.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { ErrorMessages } = require(`${__dirname}/../util/errors`)
const Discord = require('discord.js')

function embedValues(object, message){

Expand All @@ -15,16 +14,13 @@ function embedValues(object, message){
/* Does the user provide the argument and is it an object? */
if(!object || object && (typeof object !== 'object')){ return editedValues }

/* Change the values */
if(object.title) editedValues.title = object.title
/* Changes the values */
if(object.title && object.title.toString().length < 257 ) editedValues.title = object.title
if(object.color) editedValues.color = object.color
if(object.picture) editedValues.picture = object.picture
if(object.footer) editedValues.footer = object.footer
if(object.footer && object.footer.toString().length < 2049 ) editedValues.footer = object.footer
if(object.channel) editedValues.channel = message.guild.channels.cache.get(object.channel)

/* Checks if the channel is a real channel */
if (!editedValues.channel instanceof Discord.TextChannel){ throw ErrorMessages.unableToGetChannel }

/* Return the edited values to use in send() */
return editedValues
}
Expand Down
15 changes: 9 additions & 6 deletions src/util/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@ const Discord = require('discord.js')
const { embedValues } = require(`${__dirname}/embedValues`)

async function send(value, message, mentions){
const embedInfo = embedValues(value, message)

const { title, color, picture, footer, channel } = embedValues(value, message)

const embed = new Discord.MessageEmbed()
.setTitle(`${embedInfo.title}`)
.setTitle(`${title}`)
.setAuthor(`${message.member.user.tag}`, `${message.member.user.displayAvatarURL()}`)
.setColor(`${embedInfo.color}`)
.setThumbnail(`${embedInfo.picture}`)
.setColor(`${color}`)
.setThumbnail(`${picture}`)
.addFields(
{ name: `**Channel:**`, value: `${message.channel}`, inline: true },
{ name: `**Mentions:**`, value: `${mentions}`, inline: true }
)
.setFooter(`${embedInfo.footer}`)
.setFooter(`${footer}`)
.setTimestamp();

embedInfo.channel.send({embed}).catch(() => {
if (!channel instanceof Discord.TextChannel && !channel instanceof Discord.NewsChannel){ throw ErrorMessages.unableToGetChannel }

await channel.send({embed}).catch(() => {
throw ErrorMessages.unableToSendMessage
})

Expand Down

0 comments on commit 7eb5dd3

Please sign in to comment.