Skip to content

Commit bbda381

Browse files
author
xyzjesper
committed
Added Vote Role to Bot-List-Vote and Top.gg-Vote.
1 parent 7b6241f commit bbda381

File tree

16 files changed

+309
-17
lines changed

16 files changed

+309
-17
lines changed

prisma/schema.prisma

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ model TicketSetups {
428428
AutoCloseAfterTime Int?
429429
AutoAssignHandler String?
430430
AutoReplyMessageTemplateId String?
431+
TicketRateLimit String?
432+
TicketStatusMessageTemplateId String?
433+
TicketStatusMessageId String?
434+
TicketStatusChannelId String?
431435
AutoCloseAction String[] // LOOK (THREAD), ARCHIVE (BOTH), MOVE_TO_OLD_CHANNEL (Channel), DELETE (BOTH), WITH_CONFIRM (BOTH), TRANSCRIPT (BOTH), REASON (BOTH), REMOVE_USER_FROM_TICKET (BOTH) - !!! SUGGEST MORE !!!
432436
OldTicketCategoryId String?
433437
RequiredRoles String[]
@@ -572,6 +576,7 @@ model Users {
572576
Vanitys Vanitys[]
573577
Votes Int @default(0)
574578
GloablVotes Int @default(0)
579+
LastVote DateTime?
575580
// CURRENTLY NO USE!
576581
CustomerBots Int @default(1)
577582
BackupCount Int @default(10000)

src/api/services/vote.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Webhook, WebhookPayload} from "@top-gg/sdk";
22
import bodyParser from "body-parser";
3-
import {EmbedBuilder, WebhookClient} from "discord.js";
3+
import {EmbedBuilder, User, WebhookClient} from "discord.js";
44
import express, {Request, Response} from "express";
55
import {ExtendedClient} from "../../types/client.js";
66
import {Logger} from "../../main/logger.js";
@@ -22,16 +22,20 @@ export async function vote(client: ExtendedClient) {
2222
}
2323
});
2424

25-
2625
let gvotes = data?.GloablVotes as number;
2726
gvotes = gvotes + 1;
2827
let votes = data?.Votes;
2928
votes = (votes as number) + 1;
3029

30+
const voteGuild = await client.guilds.fetch(Config.Other.Vote.VoteGuildId)
31+
const voteUser = await voteGuild.members.fetch(vote.user)
32+
33+
await voteUser.roles.add(Config.Other.Vote.VoteRoleId)
34+
3135
await database.users.update(
3236
{
3337
where: {UserId: vote.user},
34-
data: {Votes: votes, GloablVotes: gvotes}
38+
data: {Votes: votes, GloablVotes: gvotes, LastVote: new Date}
3539
}
3640
);
3741

@@ -51,7 +55,7 @@ export async function vote(client: ExtendedClient) {
5155
});
5256
const user = await client.users.fetch(vote.user);
5357

54-
webhook.send({
58+
await webhook.send({
5559
embeds: [
5660
new EmbedBuilder()
5761
.setDescription(
@@ -87,6 +91,11 @@ export async function vote(client: ExtendedClient) {
8791
}
8892
});
8993

94+
const voteGuild = await client.guilds.fetch(Config.Other.Vote.VoteGuildId)
95+
const voteUser = await voteGuild.members.fetch(vote.id)
96+
97+
await voteUser.roles.add(Config.Other.Vote.VoteRoleId)
98+
9099

91100
let gvotes = data?.GloablVotes as number;
92101
gvotes = gvotes + 1;
@@ -98,7 +107,7 @@ export async function vote(client: ExtendedClient) {
98107
await database.users.update(
99108
{
100109
where: {UserId: vote.id},
101-
data: {Votes: votes, GloablVotes: gvotes}
110+
data: {Votes: votes, GloablVotes: gvotes, LastVote: new Date}
102111
}
103112
);
104113

@@ -118,7 +127,7 @@ export async function vote(client: ExtendedClient) {
118127
});
119128
const user = await client.users.fetch(vote.id);
120129

121-
webhook.send({
130+
await webhook.send({
122131
embeds: [
123132
new EmbedBuilder()
124133
.setDescription(

src/emojis/sirengreen.png

474 Bytes
Loading

src/emojis/sirenred.png

549 Bytes
Loading

src/emojis/sirenyellow.png

533 Bytes
Loading

src/helper/readyHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import {api} from "../api/restAPI/api.js";
32
import {app} from "../api/services/app.js";
43
import {emojiCache} from "../api/services/emojiCache.js";
@@ -35,9 +34,10 @@ export async function clientReady(client: ExtendedClient) {
3534
// AutoDelete
3635
await Scheduler.deleteMessagesFromAutoDelete(client);
3736

38-
// Schedule Vanity URL's
37+
// Schedule Vanity URL's && Vote Role on Guild
3938
setInterval(async () => {
4039
Scheduler.checkLast30DaysVanities(client);
40+
Scheduler.checkVoteRoles(client);
4141
}, 86400000); // 24 hours
4242

4343
// Notfiy

src/main/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export async function configStartup() {
5050
DcBotListSecret: "",
5151
TopggToken: "",
5252
VotePort: 0,
53+
VoteRoleId: "",
54+
VoteGuildId: ""
5355
},
5456
AppPort: 0,
5557
API: {

src/prisma/edge.js

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/prisma/index-browser.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,10 @@ exports.Prisma.TicketSetupsScalarFieldEnum = {
437437
AutoCloseAfterTime: 'AutoCloseAfterTime',
438438
AutoAssignHandler: 'AutoAssignHandler',
439439
AutoReplyMessageTemplateId: 'AutoReplyMessageTemplateId',
440+
TicketRateLimit: 'TicketRateLimit',
441+
TicketStatusMessageTemplateId: 'TicketStatusMessageTemplateId',
442+
TicketStatusMessageId: 'TicketStatusMessageId',
443+
TicketStatusChannelId: 'TicketStatusChannelId',
440444
AutoCloseAction: 'AutoCloseAction',
441445
OldTicketCategoryId: 'OldTicketCategoryId',
442446
RequiredRoles: 'RequiredRoles',
@@ -562,6 +566,7 @@ exports.Prisma.UsersScalarFieldEnum = {
562566
UserId: 'UserId',
563567
Votes: 'Votes',
564568
GloablVotes: 'GloablVotes',
569+
LastVote: 'LastVote',
565570
CustomerBots: 'CustomerBots',
566571
BackupCount: 'BackupCount'
567572
};

0 commit comments

Comments
 (0)