Skip to content

Commit

Permalink
fix: a lot more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexogamer committed May 15, 2021
1 parent 098abfa commit 6e246d2
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 59 deletions.
4 changes: 2 additions & 2 deletions Commands/Private/stats.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { MessageEmbed } = require("discord.js");
const os = require("os");
import { MessageEmbed } from "discord.js";
import * as os from ("os");

module.exports = async(client, msg, suffix) => {
const DTS = config.dtsEmoji;
Expand Down
2 changes: 0 additions & 2 deletions Commands/Public/block.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import embeds from "../../configuration/embeds";

module.exports = async(client, msg, suffix) => {
if (!suffix) return msg.channel.send({ embed: { color: config.colors.info, title: "Command usage", description: "To (un)block a number: >block [number]" } });

Expand Down
1 change: 0 additions & 1 deletion Commands/Public/call.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { v4 as uuidv4 } from "uuid";
import embeds from "../../configuration/embeds";

module.exports = async(client, msg, suffix, rcall) => {
let csCall;
Expand Down
51 changes: 25 additions & 26 deletions Commands/Public/coinflip.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
// @ts-check
module.exports = async(client, msg, suffix) => {
if (!suffix || !["heads", "tails"].includes(suffix.split(" ")[0].toLowerCase())) return msg.channel.send({ embed: { color: config.colors.info, description: "Are you confident in your guessing skills? Then ~~waste~~ win some money with coinflip!\nUsage: `>coinflip [heads|tails] [amount]`" } });
if (!suffix || !["heads", "tails"].includes(suffix.split(" ")[0].toLowerCase())) return msg.channel.send({ embed: { color: config.colors.info, description: "Are you confident in your guessing skills? Then ~~waste~~ win some money with coinflip!\nUsage: `>coinflip [heads|tails] [amount]`" } });

const type = suffix.split(" ")[0].toLowerCase() === "heads" ? 0 : 1;
let bet = parseInt(suffix.split(" ")[1]);
const type = suffix.split(" ")[0].toLowerCase() === "heads" ? 0 : 1;
let bet = parseInt(suffix.split(" ")[1]);

if (!bet || bet < 5) {
msg.channel.send({ embed: { color: config.colors.info, description: "We're not playing for free, I've set your bet to <:DTS:668551813317787659>5" } });
bet = 5;
} else if (bet > 250) {
msg.channel.send("Hoho, you may be rich but the maximum betting amount is <:DTS:668551813317787659>250. I've lowered it for you.");
bet = 250;
}
if (!bet || bet < 5) {
msg.channel.send({ embed: { color: config.colors.info, description: "We're not playing for free, I've set your bet to <:DTS:668551813317787659>5" } });
bet = 5;
} else if (bet > 250) {
msg.channel.send("Hoho, you may be rich but the maximum betting amount is <:DTS:668551813317787659>250. I've lowered it for you.");
bet = 250;
}

const account = await msg.author.account();
if (!account.balance || account.balance < bet) msg.channel.send({ embed: { color: config.colors.error, description: "You can't bet with money you don't even have." } });
const account = await msg.author.account();
if (!account.balance || account.balance < bet) msg.channel.send({ embed: { color: config.colors.error, description: "You can't bet with money you don't even have." } });

const side = Math.random() < .5 ? 0 : 1;
const color = config.colors.lottery;
const side = Math.random() < 0.5 ? 0 : 1;
const color = config.colors.lottery;

return msg.channel.send({ embed: { color, description: "Flipping the coin..." } }).then(async(m) => {
const balance = account.balance + Math.ceil(((side === type ? .85 : -1) * bet));
await r.table("Accounts").get(msg.author.id).update({ balance });
const title = `Landed on ${side === 0 ? "heads" : "tails"}`
const description = type === side ?
`Congratulations! You've won <:DTS:668551813317787659>${Math.ceil(bet * .85)}`
: `Thanks for your credits, I'll be ~~gambling~~ spending them well!`;

setTimeout(() => {
m.edit({ embed: { title, description, color } });
}, 2500);
});
return msg.channel.send({ embed: { color, description: "Flipping the coin..." } }).then(async(m) => {
const balance = account.balance + Math.ceil((side === type ? 0.85 : -1) * bet);
await r.table("Accounts").get(msg.author.id).update({ balance });
const title = `Landed on ${side === 0 ? "heads" : "tails"}`;
const description = type === side ?
`Congratulations! You've won <:DTS:668551813317787659>${Math.ceil(bet * 0.85)}` :
`Thanks for your credits, I'll be ~~gambling~~ spending them well!`;
setTimeout(() => {
m.edit({ embed: { title, description, color } });
}, 2500);
});
};
7 changes: 3 additions & 4 deletions Commands/Public/contacts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { MessageEmbed } from "discord.js";
import embeds from "../../configuration/embeds";

module.exports = async(client, msg) => {
const myNumber = await msg.channel.number;
Expand Down Expand Up @@ -70,7 +69,7 @@ module.exports = async(client, msg) => {
let getNumber = async bad => {
if (!perm) {
msg.author.busy = false;
return msg.channel.send({ embed: { color: config.colors.error, title: "Insufficient permission", description: "You need manage server permission to do this." } });
return msg.channel.send({ embed: embeds.requiresManageGuild });
}
if (contacts.length >= 10) msg.channel.send({ embed: { color: config.colors.error, title: "Too many contacts", description: "We currently do not allow more than 9 contacts." } });

Expand Down Expand Up @@ -170,7 +169,7 @@ module.exports = async(client, msg) => {
// check for perm & if the contact is legit
if (!perm) {
msg.author.busy = false;
return msg.channel.send({ embed: { color: config.colors.error, title: "Insufficient perms", description: "You need the Manage Server permission to do this." } });
return msg.channel.send({ embed: embeds.requiresManageGuild });
}

omsg = await msg.channel.send({ embed: {
Expand Down Expand Up @@ -239,7 +238,7 @@ module.exports = async(client, msg) => {
if (/delete/i.test(collected.first().content.split(" ")[0])) {
msg.author.busy = false;
// check for perm & if the contact is legit
if (!perm) return msg.channel.send({ embed: { color: config.colors.error, title: "Insufficient permission", description: "You need manage server permission to do this." } });
if (!perm) return msg.channel.send({ embed: embeds.requiresManageGuild });

// Delete the contact's entry
contacts.splice(contacts.indexOf(contact), 1);
Expand Down
3 changes: 1 addition & 2 deletions Commands/Public/mailbox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { MessageEmbed } from "discord.js";
import embeds from "../../configuration/embeds.js";

module.exports = async(client, msg, suffix) => {
// get the number
Expand Down Expand Up @@ -97,7 +96,7 @@ module.exports = async(client, msg, suffix) => {
} });
} else if (suffix.split(" ")[0].toLowerCase() == "delete") {
// deleting mailbox
if (!perm) return msg.channel.send({ embed: { color: config.colors.error, title: "Permission error", description: "You need the manage guild permission for this." } });
if (!perm) return msg.channel.send({ embed: embeds.requiresManageGuild });

omsg = await msg.channel.send({ embed: { color: config.colors.info, title: "Confirmation", description: "Are you sure you want to delete your mailbox? Stored messages will become **unretrievable**.\nType **yes** to confirm, **no** to cancel." } });
collector = await msg.channel.awaitMessages(
Expand Down
2 changes: 0 additions & 2 deletions Commands/Public/mention.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import embeds from "../../configuration/embeds";

module.exports = async(client, msg, suffix) => {
let perms = msg.guild ? msg.guild.members.cache.get(msg.author.id).hasPermission("MANAGE_MESSAGES") : msg.author.support;

Expand Down
1 change: 0 additions & 1 deletion Commands/Public/message.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as randomstring from "randomstring";
import embeds from "../../configuration/embeds";

module.exports = async(client, msg, suffix) => {
let time = Date.now();
Expand Down
1 change: 0 additions & 1 deletion Commands/Public/promote.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { MessageEmbed } from "discord.js";
import embeds from "../../configuration/embeds";

module.exports = async(client, msg) => {
/*
Expand Down
2 changes: 0 additions & 2 deletions Commands/Public/rcall.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import embeds from "../../configuration/embeds";

module.exports = async(client, msg) => {
let fromNumber = await msg.channel.number;
if (!fromNumber) return msg.channel.send({ embed: embeds.noNumber });
Expand Down
2 changes: 1 addition & 1 deletion Commands/Public/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = async(client, msg, suffix) => {
const newPerms = await require("../../internals/modules").updatePerms(member);
return msg.channel.send({ embed: { author: { name: member.user.tag, icon_url: member.user.displayAvatarURL() }, description: `\`\`\`js\n${require("util").inspect(newPerms)}\`\`\`` } });
}

let resstr = "";
const permsArr = suffix.match(/[+-]\w*/g) || [];
permsArr.push("end");
Expand Down
4 changes: 2 additions & 2 deletions Commands/Public/upgrade.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-check

const { MessageEmbed } = require("discord.js");
import { MessageEmbed } from "discord.js";

module.exports = async(client, msg, suffix) => {
module.exports = async(client, msg) => {
// Get their details
let number = await msg.channel.number;
let vipExpiry = number ? number.vip ? new Date(number.vip.expiry) : null : null;
Expand Down
2 changes: 1 addition & 1 deletion Commands/Public/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = async(client, msg) => {

let perm = msg.channel.type === "dm" ? true : await msg.guild.members.cache.get(msg.author.id).hasPermission("MANAGE_GUILD");
if (!perm) perm = msg.author.support;
if (!perm) return msg.channel.send({ embed: { color: config.colors.error, title: "Permission error", description: "You need to have `manage guild` permission to run this command." } });
if (!perm) return msg.channel.send({ embed: embeds.requiresManageGuild });

let prefix = msg.channel.type == "dm" ? "0900" : `030${client.shard.id + 1}`;
msg.author.busy = true;
Expand Down
3 changes: 2 additions & 1 deletion Commands/Support/cinfo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { MessageEmbed } = require("discord.js");
import { MessageEmbed } from "discord.js";

module.exports = async(client, msg, suffix) => {
let call = await r.table("OldCalls").get(suffix);
if (!call) call = await r.table("Calls").get(suffix);
Expand Down
3 changes: 2 additions & 1 deletion Commands/Support/identify.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { MessageEmbed } = require("discord.js");
import { MessageEmbed } from "discord.js";

module.exports = async(client, msg, suffix) => {
let callID = suffix.split(" ")[0];
let msgID = suffix.split(" ")[1];
Expand Down
2 changes: 1 addition & 1 deletion Commands/Support/minfo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { MessageEmbed } = require("discord.js");
import { MessageEmbed } from "discord.js";

module.exports = async(client, msg, suffix) => {
let number = suffix.split(" ")[0];
Expand Down
2 changes: 1 addition & 1 deletion Commands/Support/ninfo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { MessageEmbed } = require("discord.js");
import { MessageEmbed } from "discord.js";

const reaction = "💡";

Expand Down
2 changes: 1 addition & 1 deletion Commands/Support/uinfo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { MessageEmbed } = require("discord.js");
import { MessageEmbed } from "discord.js";

const reaction = "💡";

Expand Down
8 changes: 8 additions & 0 deletions Configuration/embeds.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-inline-comments */

// This file contains a series of commonly-used embed objects.
module.exports = {
// Registry error: no number
Expand All @@ -8,4 +9,11 @@ module.exports = {
description: "This channel doesn't have a number assigned. Use >wizard to set one up, then try this command again.",
footer: `If you have any questions, please join our support server (${config.guildInvite}) or, in a channel with a number, \`>call *611\`.`,
},
// Perm error: user doesn't have Manage Guild
requiresManageGuid: {
color: config.colors.error,
title: "Insufficient permissions",
description: "This command requires the `Manage Guild` (also known as the `Manage Server`) permission. Ask an admin to run this command.",
footer: `If you have any questions, or if you think you have the Manage Guild permission, please join our support server (${config.guildInvite}) or \`>call *611\`.`,
},
};
2 changes: 1 addition & 1 deletion DTel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createLogger, format, transports } from "winston";
const DailyRotateFile = require("winston-daily-rotate-file");
const config = global.config = require("./configuration/config.js");
const aliases = global.aliases = require("./configuration/aliases.js");

const embeds = global.embeds = require ("./configuration/embeds.js");
module.exports = class extends require("kurasuta").BaseCluster {
launch() {
const client = global.client = this.client;
Expand Down
2 changes: 1 addition & 1 deletion Database/init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { db } = require("../configuration/auth.js");
import { db } from "../configuration/auth.js";

const Cache = require("../internals/Cache.js");

Expand Down
2 changes: 1 addition & 1 deletion Events/ready.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { updatePerms, perms } = require("../internals/modules");
import { updatePerms, perms } from "../internals/modules";

module.exports = async() => {
await client.shard.broadcastEval(`this.done = true`);
Expand Down
8 changes: 4 additions & 4 deletions Internals/callHandler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { MessageEmbed } = require("discord.js");
import { MessageEmbed } from "discord.js";

module.exports = async(cmd, msg, suffix, call) => {
let embed = null,
Expand Down Expand Up @@ -56,8 +56,8 @@ module.exports = async(cmd, msg, suffix, call) => {
await r.table("Calls").get(call.id).update({ connectionLost: true });

let amt = 0;
const lostInterval = setInterval(async () => {

const lostInterval = setInterval(async() => {
try {
await client.api.channels(toSend.channel).get();

Expand All @@ -82,7 +82,7 @@ module.exports = async(cmd, msg, suffix, call) => {
return client.delete(toSend.number, { force: false, log: true, origin: "callHandler" });
}
}
}, 1e4)
}, 1e4);
}

// send the msg
Expand Down

0 comments on commit 6e246d2

Please sign in to comment.