Skip to content

Commit

Permalink
v1.0.0-beta.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MotorTruck1221 committed Nov 26, 2022
1 parent fe7ca25 commit 794c0e7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
16 changes: 12 additions & 4 deletions commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ module.exports = {
const authData = await db.admins.authWithPassword(`${email}`, `${password}`);
// get the guild id from the command
const guildscount = await db.collection('links').getFullList();
const guildc = await db.collection('guilds').getFullList();
const check = await await db.collection('links').getFullList(parseInt(guildscount.length), {
filter: `guildID = ${guildid}`,
});
if (guildc.length == 0) {
return;
}
// check if the guild is in the database
// get names of all links in the database json
// get names of all the links in the json object
Expand Down Expand Up @@ -62,13 +66,17 @@ module.exports = {
if (!interaction.inGuild()) {
return interaction.reply({ content: 'You can\'t use this command in DMs'});
}
try {
interaction.reply({ content: 'Checking if you have the required role...', ephemeral: true });
try {
const db = new PocketBase(`${url}`)
const authData = await db.admins.authWithPassword(`${email}`, `${password}`);
const g = await db.collection('guilds').getFullList();
if (g.length == 0) {
return await interaction.reply({ content: 'This server isn\'t setup! Contact the server owner to run /get-started', ephemeral: true });
}
await interaction.reply({ content: 'Checking if you have the required role...', ephemeral: true });
let guildID = interaction.guild.id;
let userID = interaction.user.id;
// init db
const db = new PocketBase(`${url}`)
const authData = await db.admins.authWithPassword(`${email}`, `${password}`);
// get the guild id from the command
const guildscount = await db.collection('guilds').getFullList();
const check = await await db.collection('guilds').getFullList( parseInt(guildscount.length), {
Expand Down
29 changes: 23 additions & 6 deletions commands/proxy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Message, SlashCommandBuilder, GuildDefaultMessageNotifications, InteractionWebhook, DMChannel, EmbedBuilder } = require('discord.js');
const { Message, SlashCommandBuilder, GuildDefaultMessageNotifications, InteractionWebhook, DMChannel, EmbedBuilder, ReactionUserManager } = require('discord.js');
const { email, password, url } = require('../config.json');
const PocketBase = require('pocketbase/cjs')
const {setTimeout} = require ('timers/promises');
Expand All @@ -25,6 +25,9 @@ module.exports = {
const check = await await db.collection('links').getFullList( parseInt(guildscount.length), {
filter: `guildID = ${guildid}`,
});
if (check.length == 0) {
return;
}
// get names of all the links in the json object
let linknames = [];
for (let i = 0; i < check[0].links.length; i++) {
Expand All @@ -50,7 +53,7 @@ module.exports = {
},
async execute(interaction, args, client) {
try {
await interaction.reply({content: "Getting proxy...", ephemeral: true});
await interaction.reply({content: "Getting proxy...", ephemeral: true});
async function start() {
if (!interaction.inGuild()) {
return interaction.followUp({ content: 'You can\'t use this command in DMs'});
Expand Down Expand Up @@ -199,6 +202,13 @@ module.exports = {
filter: `userID = ${userid} && guildID = ${guildid}`,
});
let lastlink = lastusedlink[0].link;
// if the link numbers are less than 0, set the last link used to none
if (lastlink < 0) {
// set the lastlink to none with pocketbase
const update = await pdb.collection('linkused').update( usedlink[0].id, {
link: 'none',
});
}
if (lastlink === 'none') {
// update the used link
const update = await pdb.collection('linkused').update( lastusedlink[0].id, {
Expand All @@ -214,10 +224,17 @@ module.exports = {
const updated = await pdb.collection('linkused').update( lastusedlink[0].id, {
link: random
});

await interaction.followUp({ embeds: [embed], ephemeral: true });
// dm the user the link
interaction.member.send({ embeds: [embed] });
interaction.member.send({ embeds: [embed] }).then(async () => {
await interaction.followUp({ embeds: [embed], ephemeral: true });
}).catch(async (error) => {
await pdb.collection('users').update( idofuser[0].id, {numberofuses: newuses - 1});
// remove used link
const update = await pdb.collection('linkused').update( lastusedlink[0].id, {
link: 'none'
});
await interaction.followUp({ content: 'I was unable to DM you the link! Please make sure your DMs are open!', ephemeral: true });
return;
});
} else {
await interaction.followUp({ content: 'That proxy does not exist!', ephemeral: true });
return;
Expand Down
6 changes: 5 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"token": "djstoken",
"email": "email",
"password": "password",
"url": "url"
"url": "url",
"status": "watching, playing, listening, streaming",
"game": [
// an array of games to cycle through
]
}
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const fs = require('node:fs');
const path = require('node:path');
const { Client, Events, GatewayIntentBits, Collection, ActivityType } = require('discord.js');
const { token, prefix } = require('./config.json');
const { token, prefix, status, game } = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.DirectMessages] });
Expand Down Expand Up @@ -69,7 +69,9 @@ client.on(Events.InteractionCreate, async interaction => {
// When the client is ready, run this code (only once)
// We use 'c' for the event parameter to keep it separate from the already defined 'client'
client.once(Events.ClientReady, c => {
const activities = ['The Support Server!', 'Weeb Network', `${client.guilds.cache.size} SERVER(S), Beta v1.0.0 Released!`];
game.push(`${client.guilds.cache.size} servers`);
const activities = game;
//console.log(game)
const updateDelay = 5; // in seconds
let currentIndex = 0;
setInterval(() => {
Expand Down

0 comments on commit 794c0e7

Please sign in to comment.