Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #1

Merged
merged 213 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
53b8fb5
:bug: Use cache for stats command
Androz2091 Nov 25, 2020
3d7292b
:bug: Fix stats command
Androz2091 Nov 25, 2020
c5db8c7
:sparkles: Add remind messages
Androz2091 Nov 29, 2020
239091a
:arrow_up::lock: Bump bl from 2.2.0 to 2.2.1 (#111)
dependabot-preview[bot] Nov 29, 2020
6351f02
:arrow_up: Bump discord-paginationembed from 2.0.0 to 2.1.0 (#112)
dependabot-preview[bot] Nov 29, 2020
67fa885
:arrow_up: Bump ejs from 3.1.3 to 3.1.5 (#113)
dependabot-preview[bot] Nov 29, 2020
d0c71f4
:sparkles: Deploy
Androz2091 Nov 29, 2020
a3984ed
:sparkles: Run the job at midnight
Androz2091 Nov 29, 2020
17c144e
:bug: Change min date for reminders
Androz2091 Nov 29, 2020
08e5f22
:bug: Fix invites counting
Androz2091 Dec 1, 2020
d9349d1
:sparkles: Fix reminds
Androz2091 Dec 1, 2020
f2582c8
:bug: Fix blacklist command
Androz2091 Dec 1, 2020
72fc029
:sparkles: Add cooldown
Androz2091 Dec 2, 2020
980c83c
:alien: Update translations
Androz2091 Dec 2, 2020
bfa5988
:bug: Fix cooldown for stats command
Androz2091 Dec 2, 2020
9c211f6
:sparkles: Parse cooldown for stats command
Androz2091 Dec 2, 2020
3136acf
:sparkles: It should work now
Androz2091 Dec 3, 2020
1e880fe
:sparkles: Los Angeles
Androz2091 Dec 3, 2020
51f1ad9
:bug: Catch invalid locale errors
Androz2091 Jan 17, 2021
adda365
:bookmark: v4.6.3
Androz2091 Jan 17, 2021
5d6938a
:bug: Fix member count command
Androz2091 Jan 22, 2021
60e51ca
⬆️ Bump @sentry/node from 5.27.4 to 6.0.1 (#154)
dependabot-preview[bot] Jan 22, 2021
13c0bd2
⬆️🔒 Bump ini from 1.3.5 to 1.3.8 (#136)
dependabot-preview[bot] Jan 22, 2021
03adfde
⬆️ Bump pg from 8.2.1 to 8.5.1 (#116)
dependabot-preview[bot] Jan 22, 2021
cb138a0
⬆️ Bump eslint from 7.5.0 to 7.18.0 (#150)
dependabot-preview[bot] Jan 22, 2021
8cb4fd7
⬆️ Bump chart.js from 2.9.3 to 2.9.4 (#115)
dependabot-preview[bot] Jan 22, 2021
23f1da5
⬆️ Bump i18next-fs-backend from 1.0.6 to 1.0.8 (#152)
dependabot-preview[bot] Jan 22, 2021
21f496b
⬆️ Bump string-similarity from 4.0.1 to 4.0.4 (#146)
dependabot-preview[bot] Jan 22, 2021
754ba09
⬆️ Bump i18next from 19.5.1 to 19.8.4 (#121)
dependabot-preview[bot] Jan 22, 2021
d0fda80
⬆️ Bump moment from 2.27.0 to 2.29.1 (#119)
dependabot-preview[bot] Jan 22, 2021
4183429
⬆️🔒 Bump date-and-time from 0.14.1 to 0.14.2 (#141)
dependabot-preview[bot] Jan 22, 2021
04b45a5
New Crowdin updates (#108)
Androz2091 Jan 22, 2021
dda61f2
:fire: Remove mongo-to-pg files
Androz2091 Jan 22, 2021
6c98b43
:pushpin: Remove mongoose from lock file
Androz2091 Jan 22, 2021
dc52a1c
:fire: Remove partner file
Androz2091 Jan 22, 2021
b185b6b
:fire: Remove vscode/launch file
Androz2091 Jan 22, 2021
99bef9d
:art: Export languages config to a dedicated file
Androz2091 Jan 22, 2021
4c3b5fe
:sparkles: Add de-DE language
Androz2091 Jan 22, 2021
bb47307
:art: Quote props as needed for eslint
Androz2091 Jan 22, 2021
07306da
:art: Move Constants file to helpers
Androz2091 Jan 22, 2021
0ec87c6
:sparkles: Add new options on the dashboard
Androz2091 Jan 23, 2021
84f6abf
:alien: Language clean up
Androz2091 Jan 30, 2021
daf5606
:bug: Fix dashboard link
Androz2091 Jan 30, 2021
4717060
:bug: Fix roles config on dash
Androz2091 Jan 30, 2021
95e328e
:sparkles: Change doc link
Androz2091 Jan 30, 2021
2f82aa7
:bug: Fix doc link
Androz2091 Jan 30, 2021
55f015b
⬆️ Bump i18next from 19.8.4 to 19.8.5 (#160)
dependabot-preview[bot] Jan 30, 2021
b927114
⬆️ Bump chartjs-node-canvas from 3.0.6 to 3.0.8 (#159)
dependabot-preview[bot] Jan 30, 2021
5bfec87
⬆️ Bump @sentry/node from 6.0.1 to 6.0.2 (#158)
dependabot-preview[bot] Jan 30, 2021
6c28a13
⬆️ Bump ms from 2.1.2 to 2.1.3 (#157)
dependabot-preview[bot] Jan 30, 2021
78c24a9
:sparkles: Embed and fake threshold
Androz2091 Feb 1, 2021
9779817
⬆️ Bump @sentry/node from 6.0.2 to 6.0.3 (#162)
dependabot-preview[bot] Feb 1, 2021
9eb8182
⬆️ Bump eslint from 7.18.0 to 7.19.0 (#161)
dependabot-preview[bot] Feb 1, 2021
750f33d
New Crowdin updates (#156)
Androz2091 Feb 1, 2021
1b413d2
:sparkles: Thai language
Androz2091 Feb 1, 2021
e60599d
New Crowdin updates (#164)
Androz2091 Feb 1, 2021
3822b5d
:bug: Fix thai language
Androz2091 Feb 1, 2021
47bb55e
:sparkles: Add variables file
Androz2091 Feb 1, 2021
71f6d6b
New Crowdin updates (#166)
Androz2091 Feb 4, 2021
dc7e298
⬆️ Bump i18next from 19.8.5 to 19.8.7 (#170)
dependabot-preview[bot] Feb 4, 2021
e1cc2fa
⬆️ Bump chartjs-node-canvas from 3.0.8 to 3.1.0 (#169)
dependabot-preview[bot] Feb 4, 2021
055793f
⬆️ Bump @sentry/node from 6.0.3 to 6.0.4 (#167)
dependabot-preview[bot] Feb 5, 2021
7990341
⬆️ Bump @sentry/node from 6.0.3 to 6.1.0 (#171)
dependabot-preview[bot] Feb 5, 2021
b80e2ad
:sparkles: Add join fake and add variable alias
Androz2091 Feb 5, 2021
5d8458b
:bug: Some variable names fixes
Androz2091 Feb 5, 2021
5a0caec
:bug: Change test num joins
Androz2091 Feb 5, 2021
0f302dc
:bug: Fix num joins before locale
Androz2091 Feb 5, 2021
21b0058
:sparkles: Save invite channel
Androz2091 Feb 5, 2021
121760a
:bookmark: v4.7.0
Androz2091 Feb 5, 2021
e58e07e
:bug: Fix stats command
Androz2091 Feb 5, 2021
580cdf8
:bookmark: v4.7.1
Androz2091 Feb 5, 2021
48d714c
:bug: Fix inviter name variable
Androz2091 Feb 5, 2021
b0c3a3c
⬆️ Bump @sentry/node from 6.1.0 to 6.2.0 (#177)
dependabot-preview[bot] Feb 20, 2021
1172f35
⬆️ Bump i18next from 19.8.7 to 19.8.9 (#176)
dependabot-preview[bot] Feb 20, 2021
41967d4
⬆️ Bump eslint from 7.19.0 to 7.20.0 (#174)
dependabot-preview[bot] Feb 20, 2021
44d02ea
⬆️ Bump ejs from 3.1.5 to 3.1.6 (#173)
dependabot-preview[bot] Feb 20, 2021
e0fca62
New Crowdin updates (#172)
Androz2091 Feb 20, 2021
611c033
:bug: Fix sub
Androz2091 Feb 22, 2021
ee0c6db
:bug: Reduce length to 800 for sub
Androz2091 Feb 22, 2021
2335a0e
:bug: reduce length again
Androz2091 Feb 22, 2021
29f2c87
:bug: debug content length
Androz2091 Feb 22, 2021
a478d88
:bug: Increase to 900
Androz2091 Feb 22, 2021
e036e65
:bug: fix sub command
Androz2091 Feb 26, 2021
1169bcf
:sparkles: Start working on Redis
Androz2091 Feb 26, 2021
4f184f6
:sparkles: Add some new functions
Androz2091 Feb 26, 2021
0bc6757
:recycle: Rewrite logger
Androz2091 Feb 26, 2021
84da5d7
:fire: Remove usage statistics
Androz2091 Feb 26, 2021
feb57cd
:sparkles: Add postgres function
Androz2091 Feb 26, 2021
e97c14a
:sparkles: do more
Androz2091 Mar 3, 2021
0f3f100
some fixes
Androz2091 Mar 3, 2021
3eaffe6
working
Androz2091 Mar 3, 2021
db3dfb2
some update
Androz2091 Mar 3, 2021
0125b99
working
Androz2091 Mar 5, 2021
7e03c42
update
Androz2091 Mar 5, 2021
24fafff
add new functions
Androz2091 Mar 6, 2021
ae7c781
:sparkles: implement backup ID
Androz2091 Mar 9, 2021
f76f413
:sparkles: YEAH
Androz2091 Mar 9, 2021
a224651
fixed some grammar mistakes :)) (#184)
Kabir-Sidhu Mar 9, 2021
9e0899e
:sparkles: Use storage
Androz2091 Mar 11, 2021
1e16f6e
:sparkles: Add leaderboard
Androz2091 Mar 11, 2021
240b1d2
:sparkles: Huge redis update
Androz2091 Mar 11, 2021
ea8ba6c
:sparkles: Add sync ranks command
Androz2091 Mar 11, 2021
fb398b0
:zap: Optimization
Androz2091 Mar 11, 2021
0459ae0
:sparkles: feature
Androz2091 Mar 11, 2021
b73daf8
:sparkles: subscription command works
Androz2091 Feb 22, 2021
e49fb14
:sparkles: Many fixes
Androz2091 Mar 15, 2021
0d67785
:sparkles: Payments
Androz2091 Mar 15, 2021
af2bb15
:sparkles: Dashboard is working
Androz2091 Mar 15, 2021
e3cf6e4
:fire: Remove previous db files
Androz2091 Mar 15, 2021
b297220
:sparkles: guild member remove
Androz2091 Mar 15, 2021
089b4ff
:sparkles: Add some features
Androz2091 Mar 15, 2021
890b742
:sparkles: Update userinfo
Androz2091 Mar 15, 2021
2c6348f
:sparkles: Add redis stats on botinfos
Androz2091 Mar 15, 2021
4027f04
:sparkles: Convert some files
Androz2091 Mar 15, 2021
0aa2f73
:bug: Fix syntax error
Androz2091 Mar 15, 2021
dfcff45
:pencil: typo
Androz2091 Mar 15, 2021
44db8b2
:sparkles: Add some features
Androz2091 Mar 16, 2021
3ce06e0
:sparkles: Add blacklist
Androz2091 Mar 16, 2021
fa571db
:bug: Some fixes
Androz2091 Mar 16, 2021
2857bec
:sparkles: addpremium
Androz2091 Mar 16, 2021
c9ae421
:sparkles: Some fixes
Androz2091 Mar 16, 2021
0bf97c2
:fire: remove pop json
Androz2091 Mar 16, 2021
dc082c0
:bug: Fix guildMemberAdd event
Androz2091 Mar 16, 2021
566a6aa
:pencil: Document redis
Androz2091 Mar 16, 2021
e8135fb
:pencil: Document PostgreSQL
Androz2091 Mar 16, 2021
46e0437
:pencil: Document database
Androz2091 Mar 16, 2021
256e8dc
:fire: remove camel case
Androz2091 Mar 16, 2021
3b2b136
:fire: Remove useless dependencies
Androz2091 Mar 16, 2021
fcfc97b
:fire: remove passport
Androz2091 Mar 16, 2021
7d160ab
:fire: Remove markdown table
Androz2091 Mar 16, 2021
fcd16f5
:pushpin: Update yarn lock
Androz2091 Mar 16, 2021
1c44dc7
:wrench: Fix eslint configuration
Androz2091 Mar 17, 2021
7a9aae9
:bug: Fix some problems with subscriptions
Androz2091 Mar 17, 2021
112c7c2
:sparkles: Convert email premium
Androz2091 Mar 17, 2021
f876d11
:bug: Some eslint fixes
Androz2091 Mar 17, 2021
760e269
:art: Eslint clean up
Androz2091 Mar 17, 2021
bf7e6cb
:bug: Fix some eslint bugs
Androz2091 Mar 17, 2021
1cb0195
:wrench: Add emojis to constants
Androz2091 Mar 17, 2021
1f8da8e
:fire: Remove some things from config sample
Androz2091 Mar 17, 2021
761e981
:zap: Database optimizations
Androz2091 Mar 18, 2021
21e8bb6
:sparkles: Add migration script
Androz2091 Mar 19, 2021
bb917a6
:zap: Optimize script
Androz2091 Mar 21, 2021
c0e775a
:sparkles: Redis
Androz2091 Mar 21, 2021
cc59a29
:bug: Use default database in script
Androz2091 Mar 21, 2021
9092ee4
:sparkles: Add confirm
Androz2091 Mar 21, 2021
2d2bc25
:bug: Fix config sample
Androz2091 Mar 21, 2021
292b0e2
:zap: Update migration script
Androz2091 Mar 21, 2021
9b60a9a
:zap: Update migration script
Androz2091 Mar 21, 2021
bee112f
:bug: Fix migration script
Androz2091 Mar 21, 2021
cc26719
:zap: Add some dependencies
Androz2091 Mar 21, 2021
4f5e233
:zap: Add utf-8-validate
Androz2091 Mar 21, 2021
cd8cd60
:bug: Fix imports
Androz2091 Mar 23, 2021
52b865f
:bug: Fix guild leaderboard value type
Androz2091 Mar 23, 2021
b6f37f7
:bug: Fix language on help command
Androz2091 Mar 23, 2021
be4d0f1
:pencil: Update help content
Androz2091 Mar 23, 2021
c7f35bf
:bug: Fix calculate invite in database
Androz2091 Mar 23, 2021
9bb04e8
:bug: Fix invite calculation
Androz2091 Mar 23, 2021
7b2931e
add more logs
Androz2091 Mar 23, 2021
ed6a119
:bug: Fix fetch guild member
Androz2091 Mar 23, 2021
d57974e
:bug: Fix number of invites for logging messages
Androz2091 Mar 23, 2021
734d5f2
:mute: Remove useless logs
Androz2091 Mar 23, 2021
bee7aa2
:loud_sound: Add new logs
Androz2091 Mar 23, 2021
ed48deb
:fire: Remove useless await
Androz2091 Mar 23, 2021
6d69b90
:zap: Improve migration script
Androz2091 Mar 24, 2021
592b769
:sparkles: Add time confirmation
Androz2091 Mar 24, 2021
3384076
:sparkles: Fix migration script
Androz2091 Mar 24, 2021
21df70b
:bug: Fix cancel-premium command
Androz2091 Mar 27, 2021
3fa67ec
:bug: Some other fixes
Androz2091 Mar 27, 2021
e7ce197
:bug: Reduce leaderboard time
Androz2091 Mar 27, 2021
b5d1d54
:bug: Fix guild settings
Androz2091 Mar 27, 2021
d280796
:bug: Fix guild plugins
Androz2091 Mar 27, 2021
7db62cd
:bug: FIx config
Androz2091 Mar 27, 2021
b8af5a0
:bug: Fix addbonus
Androz2091 Mar 27, 2021
258b509
:bug: Fix leave and join logs
Androz2091 Mar 27, 2021
3fb8fed
:bug: fix translations
Androz2091 Mar 27, 2021
b15888b
:bug: Fix events
Androz2091 Mar 27, 2021
0975908
:bug: Fix create guild member event
Androz2091 Mar 27, 2021
914a2c7
:bug: Fix userinfo command
Androz2091 Mar 27, 2021
0576d3a
:bug: Some fixes
Androz2091 Mar 27, 2021
2d1edfc
:bug: Remove guild invites before sync
Androz2091 Mar 27, 2021
7b0d681
:bug: Fix migration script
Androz2091 Mar 27, 2021
036670e
:bug: fix migration script
Androz2091 Mar 27, 2021
c07c00d
:bug: Fix migration script again
Androz2091 Mar 27, 2021
4e2c5c3
:bug: Fix joinDM
Androz2091 Mar 27, 2021
ee1757b
:bug: Fix leave message
Androz2091 Mar 27, 2021
f6b90fb
:bug: Fix partial members
Androz2091 Mar 27, 2021
d5c079c
:bug: fix guild member add
Androz2091 Mar 27, 2021
c38cada
:mute: Disable logs
Androz2091 Mar 27, 2021
e94d4da
:sparkles: Add more logs
Androz2091 Mar 27, 2021
b598b56
:sparkles: Add time
Androz2091 Mar 27, 2021
29d5a63
:bug: Fix logs
Androz2091 Mar 27, 2021
69dd132
:bug: Fix logs
Androz2091 Mar 27, 2021
267dbb7
:bug: Check if member exists
Androz2091 Mar 27, 2021
d181429
:bug: Fix leave message
Androz2091 Mar 27, 2021
7198373
:fire: Delete scripts
Androz2091 Mar 27, 2021
63cc630
:sound: Add some additional logs
Androz2091 Mar 27, 2021
5d96c87
:bug: Set default join count to 1
Androz2091 Mar 27, 2021
512137e
:ambulance: Fix fetch member events
Androz2091 Mar 27, 2021
fd95bc0
:bug: Fix guild create event
Androz2091 Mar 27, 2021
8f838a8
New Crowdin updates (#178)
Androz2091 Mar 27, 2021
6f027a1
⬆️ Bump i18next from 19.9.2 to 20.1.0 (#194)
dependabot-preview[bot] Mar 27, 2021
0c582d6
⬆️ Bump eslint from 7.20.0 to 7.23.0 (#195)
dependabot-preview[bot] Mar 27, 2021
5ce36e3
⬆️ Bump i18next-fs-backend from 1.0.8 to 1.1.0 (#180)
dependabot-preview[bot] Mar 27, 2021
3c0ac95
⬆️ Bump redis-modules-sdk from 0.4.1 to 0.4.4 (#192)
dependabot-preview[bot] Mar 27, 2021
9f0cadd
⬆️ Bump @sentry/node from 6.2.0 to 6.2.3 (#191)
dependabot-preview[bot] Mar 27, 2021
6a249c4
:bookmark: v4.8.0
Androz2091 Mar 27, 2021
a47dd04
:fire: Remove yarn error log
Androz2091 Mar 27, 2021
8b7bfd8
:bug: Fix invalid removing of invites
Androz2091 Mar 28, 2021
1798f16
:bug: Fix sync invites
Androz2091 Mar 28, 2021
ef9d4f2
:bug: Fix decrease of leaves
Androz2091 Mar 28, 2021
2da5425
:bookmark: v4.8.1
Androz2091 Mar 28, 2021
43e5662
:fire: Remove btoa
Androz2091 Mar 28, 2021
488f982
:bug: Remove auto sync on join
Androz2091 Mar 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
Expand Down Expand Up @@ -48,6 +48,7 @@
"after": true
}
],
"quote-props": ["error", "as-needed"],
"require-atomic-updates": 0,
"no-async-promise-executor": 0
}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Node
node_modules/
package-lock.json
yarn*.log

# Conf
config.js
Expand Down
17 changes: 0 additions & 17 deletions .vscode/launch.json

This file was deleted.

8 changes: 0 additions & 8 deletions Constants.js

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ We're sorry but we won't be able to help you to install the bot on your own serv

## 🌐 Dashboard

ManageInvite has a powerful dashboard which allow you to manage your servers easily! Configure join/leave messages, change server prefix, server language, etc...
ManageInvite has a powerful dashboard which allows you to manage your servers easily! Configure join/leave messages, change server prefix, server language, etc...

<img src="./assets/selector.png" style="margin-right: 2px;width: 40%;" ></img>
<img src="./assets/manage.png" style="margin-right: 2px;width: 40%;" ></img>
Expand Down
47 changes: 31 additions & 16 deletions commands/admin/addbonus.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,48 @@ module.exports = class extends Command {

async run (message, args, data) {

const blacklistedUsers = await this.client.database.fetchGuildBlacklistedUsers(message.guild.id);

const bonus = args[0];
if (!bonus) return message.error("admin/addbonus:MISSING_AMOUNT", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
});
if (isNaN(bonus) || (parseInt(bonus) < 1) || !Number.isInteger(parseInt(bonus))) return message.error("admin/addbonus:INVALID_AMOUNT", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
});

const member = message.mentions.members.first() || await this.client.resolveMember(args.slice(1).join(" "), message.guild);
if (!member && args[1] !== "all") return message.error("admin/addbonus:MISSING_TARGET", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
});
if (member){
if (data.guild.blacklistedUsers.includes(member.id)){
if (blacklistedUsers.includes(member.id)){
return message.error("admin/blacklist:BLACKLISTED", {
username: member.user.username
});
}
const memberData = await this.client.database.fetchMember(member.id, message.guild.id);
memberData.bonus += parseInt(bonus);
await memberData.updateInvites();
const memberData = await this.client.database.fetchGuildMember({
userID: member.user.id,
guildID: message.guild.id,
storageID: message.guild.settings.storageID
});
if (memberData.notCreated) await this.client.database.createGuildMember({
userID: member.user.id,
guildID: message.guild.id,
storageID: message.guild.settings.storageID
});
await this.client.database.addInvites({
userID: member.user.id,
guildID: message.guild.id,
storageID: message.guild.settings.storageID,
number: parseInt(bonus),
type: "bonus"
});

const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("admin/addbonus:SUCCESS_TITLE"))
.setDescription(message.translate("admin/addbonus:SUCCESS_CONTENT_MEMBER", {
prefix: data.guild.prefix,
prefix: message.guild.settings.prefix,
usertag: member.user.tag,
username: member.user.username
}))
Expand All @@ -57,18 +73,17 @@ module.exports = class extends Command {

await conf.sendT("misc:PLEASE_WAIT", null, true, false, "loading");
await message.guild.members.fetch();
const members = message.guild.members.cache.map((m) => {
return {
userID: m.id,
guildID: message.guild.id
};
await this.client.database.addGuildInvites({
userIDs: message.guild.members.cache.map((m) => m.id),
guildID: message.guild.id,
storageID: message.guild.settings.storageID,
number: parseInt(bonus),
type: "bonus"
});
await this.client.database.fetchMembers(members);
await this.client.database.addBonusInvitesMembers(message.guild.id, bonus);
const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("admin/addbonus:SUCCESS_TITLE"))
.setDescription(message.translate("admin/addbonus:SUCCESS_CONTENT_ALL", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
}))
.setColor(data.color)
.setFooter(data.footer);
Expand Down
20 changes: 12 additions & 8 deletions commands/admin/addrank.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,43 @@ module.exports = class extends Command {
}

async run (message, args, data) {


const inviteCount = args[0];
if (!inviteCount) return message.error("admin/addrank:MISSING_COUNT", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
});
if (isNaN(inviteCount) || parseInt(inviteCount) < 1 || !Number.isInteger(parseInt(inviteCount))) return message.error("admin/addrank:INCORRECT_COUNT", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
});
let currentRank = data.guild.ranks.find((r) => r.inviteCount === inviteCount) || {};

const guildRanks = await this.client.database.fetchGuildRanks(message.guild.id);

let currentRank = guildRanks.find((r) => r.inviteCount === inviteCount) || {};
const currentRole = message.guild.roles.cache.find((r) => r.id === currentRank.roleID);
if (currentRank && currentRole) return message.error("admin/addrank:ALREADY_EXIST", {
prefix: data.guild.prefix,
prefix: message.guild.settings.prefix,
count: currentRank.inviteCount,
roleName: currentRole.name,
roleID: currentRole.id
});

const role = message.mentions.roles.first() || message.guild.roles.cache.get(args.slice(1).join(" ")) || message.guild.roles.cache.find((role) => role.name === args.slice(1).join(" ") || (stringSimilarity.compareTwoStrings(role.name, args.slice(1).join(" ")) > 0.85));
if (!role) return message.error("admin/addrank:MISSING_ROLE", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
});
if (role.managed || role.id === message.guild.id) return message.error("admin/addrank:MANAGED");
if (role.position > message.guild.me.roles.highest.position) return message.error("admin/addrank:MISSING_PERM", {
roleName: role.name
});
currentRank = data.guild.ranks.find((r) => r.roleID === role.id);
currentRank = guildRanks.find((r) => r.roleID === role.id);
if (currentRank) return message.error("admin/addrank:ALREADY_USED", {
prefix: data.guild.prefix,
prefix: message.guild.settings.prefix,
count: currentRank.inviteCount,
roleID: role.id
});

await data.guild.addRank(role.id, inviteCount);
await this.client.database.addGuildRank(message.guild.id, role.id, inviteCount);

const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("admin/addrank:TITLE"))
Expand Down
23 changes: 16 additions & 7 deletions commands/admin/blacklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@ module.exports = class extends Command {
}

async run (message, args, data) {

const guildBlacklistedUsers = await this.client.database.fetchGuildBlacklistedUsers(message.guild.id);

const embed = new Discord.MessageEmbed()
.setColor(data.color)
.setFooter(data.footer);
const action = args[0];
switch (action){
case "add": {
const user = message.mentions.users.first() || await this.client.users.fetch(args[0]).catch(() => {});
const user = message.mentions.users.first() || await this.client.users.fetch(args[1]).catch(() => {});
if (!user) return message.error("admin/blacklist:MISSING_MEMBER_ADD");
if (data.guild.blacklistedUsers.includes(user.id)) return message.error("admin/blacklist:ALREADY_BLACKLISTED", {
if (guildBlacklistedUsers.includes(user.id)) return message.error("admin/blacklist:ALREADY_BLACKLISTED", {
username: user.tag
});
await data.guild.addUserBlacklist(user.id);
await this.client.database.addGuildBlacklistedUser({
guildID: message.guild.id,
userID: user.id
});
message.success("admin/blacklist:SUCCESS_MEMBER_ADD", {
username: user.tag
});
Expand All @@ -33,21 +39,24 @@ module.exports = class extends Command {
case "remove": {
const user = message.mentions.users.first() || await this.client.users.fetch(args[1]).catch(() => {});
if (!user) return message.error("admin/blacklist:MISSING_MEMBER_REMOVE");
if (!data.guild.blacklistedUsers.includes(user.id)) return message.error("admin/blacklist:NOT_BLACKLISTED", {
if (!guildBlacklistedUsers.includes(user.id)) return message.error("admin/blacklist:NOT_BLACKLISTED", {
username: user.tag
});
await data.guild.removeUserBlacklist(user.id);
await this.client.database.removeGuildBlacklistedUser({
guildID: message.guild.id,
userID: user.id
});
message.success("admin/blacklist:SUCCESS_MEMBER_REMOVE", {
username: user.tag
});
break;
}
case "list": {
if (data.guild.blacklistedUsers.length < 1){
if (guildBlacklistedUsers.length < 1){
embed.setDescription(message.translate("admin/blacklist:EMPTY"));
} else {
const users = [];
await this.client.functions.asyncForEach(data.guild.blacklistedUsers, async (userID) => {
await this.client.functions.asyncForEach(guildBlacklistedUsers, async (userID) => {
const user = await this.client.users.fetch(userID);
users.push(`${user.tag} (${user.toString()})`);
});
Expand Down
8 changes: 5 additions & 3 deletions commands/admin/ranks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Command = require("../../structures/Command.js"),
Discord = require("discord.js"),
Constants = require("../../Constants");
Constants = require("../../helpers/constants");

module.exports = class extends Command {
constructor (client) {
Expand All @@ -14,16 +14,18 @@ module.exports = class extends Command {
}

async run (message, args, data) {

const guildRanks = await this.client.database.fetchGuildRanks(message.guild.id);

const embed = new Discord.MessageEmbed()
.setColor(data.color)
.setFooter(data.footer);

const ranks = data.guild.ranks.sort((a,b) => b.inviteCount - a.inviteCount);
const ranks = guildRanks.sort((a,b) => b.inviteCount - a.inviteCount);
if (ranks.length === 0){
embed.setAuthor(message.translate("admin/ranks:NO_RANK_TITLE"))
.setDescription(message.translate("admin/ranks:NO_RANK_CONTENT", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
}));
return message.channel.send(embed);
}
Expand Down
47 changes: 31 additions & 16 deletions commands/admin/removebonus.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,47 @@ module.exports = class extends Command {

async run (message, args, data) {

const guildBlacklistedUsers = await this.client.database.fetchGuildSubscriptions(message.guild.id);

const bonus = args[0];
if (!bonus) return message.error("admin/removebonus:MISSING_AMOUNT", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
});
if (isNaN(bonus) || parseInt(bonus) < 1 || !Number.isInteger(parseInt(bonus))) return message.error("admin/removebonus:INVALID_AMOUNT", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
});

const member = message.mentions.members.first() || await this.client.resolveMember(args.slice(1).join(" "), message.guild);
if (!member && args[1] !== "all") return message.error("admin/removebonus:MISSING_TARGET", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
});
if (member && data.guild.blacklistedUsers.includes(member.id)) return message.error("admin/blacklist:BLACKLISTED", {
if (member && guildBlacklistedUsers.includes(member.id)) return message.error("admin/blacklist:BLACKLISTED", {
username: member.user.username
});

if (member){
const memberData = await this.client.database.fetchMember(member.id, message.guild.id);
memberData.bonus -= parseInt(bonus);
await memberData.updateInvites();
const memberData = await this.client.database.fetchGuildMember({
userID: member.user.id,
guildID: message.guild.id,
storageID: message.guild.settings.storageID
});
if (memberData.notCreated) await this.client.database.createGuildMember({
userID: member.user.id,
guildID: message.guild.id,
storageID: message.guild.settings.storageID
});
await this.client.database.addInvites({
userID: member.user.id,
guildID: message.guild.id,
storageID: message.guild.settings.storageID,
number: -parseInt(bonus),
type: "bonus"
});

const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("admin/removebonus:SUCCESS_TITLE"))
.setDescription(message.translate("admin/removebonus:SUCCESS_CONTENT_MEMBER", {
prefix: data.guild.prefix,
prefix: message.guild.settings.prefix,
usertag: member.user.tag,
username: member.user.username
}))
Expand All @@ -57,18 +72,18 @@ module.exports = class extends Command {

await conf.sendT("misc:PLEASE_WAIT", null, true, false, "loading");
await message.guild.members.fetch();
const members = message.guild.members.cache.map((m) => {
return {
userID: m.id,
guildID: message.guild.id
};
await this.client.database.addGuildInvites({
userID: message.guild.members.cache.map((m) => m.id),
guildID: message.guild.id,
storageID: message.guild.settings.storageID,
number: -parseInt(bonus),
type: "bonus"
});
await this.client.database.fetchMembers(members);
await this.client.database.removeBonusInvitesMembers(message.guild.id, bonus);

const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("admin/removebonus:SUCCESS_TITLE"))
.setDescription(message.translate("admin/removebonus:SUCCESS_CONTENT_ALL", {
prefix: data.guild.prefix
prefix: message.guild.settings.prefix
}))
.setColor(data.color)
.setFooter(data.footer);
Expand Down
Loading