Skip to content

Commit

Permalink
v4 bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
saiteja-madha committed May 23, 2022
1 parent ebf6489 commit ef4aa02
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
.eslintrc*.yml
*.log
*.tar.gz
CONTRIBUTING.md
examples
docgen
docs
node_modules
test
53 changes: 53 additions & 0 deletions development-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Development

This may help you if you are editing this script

## Structures(Folders)

◟ dashboard - Website, Socket and routes

◟ src
╠ /commands - Bot commands and slash commands
╠ /events - Client events
╠ /structures - Classes
╠ /util - Extra stuffs
╠ /views - Page Rendering/Website

◟ dockerfile / docker-compose.yml
Docker is optional, read more about [Docker](https://www.docker.com/)

## Permissions

Permissions to add in commands to check them that it is available or not

`ADMINISTRATOR` (implicitly has _all_ permissions, and bypasses all channel overwrites)
`CREATE_INSTANT_INVITE` (create invitations to the guild)
`KICK_MEMBERS`
`BAN_MEMBERS`
`MANAGE_CHANNELS` (edit and reorder channels)
`MANAGE_GUILD` (edit the guild information, region, etc.)
`ADD_REACTIONS` (add new reactions to messages)
`VIEW_AUDIT_LOG`
`PRIORITY_SPEAKER`
`STREAM`
`VIEW_CHANNEL`
`SEND_MESSAGES`
`SEND_TTS_MESSAGES`
`MANAGE_MESSAGES` (delete messages and reactions)
`EMBED_LINKS` (links posted will have a preview embedded)
`ATTACH_FILES`
`READ_MESSAGE_HISTORY` (view messages that were posted prior to opening Discord)
`MENTION_EVERYONE`
`USE_EXTERNAL_EMOJIS` (use emojis from different guilds)
`VIEW_GUILD_INSIGHTS`
`CONNECT` (connect to a voice channel)
`SPEAK` (speak in a voice channel)
`MUTE_MEMBERS` (mute members across all voice channels)
`DEAFEN_MEMBERS` (deafen members across all voice channels)
`MOVE_MEMBERS` (move members between voice channels)
`USE_VAD` (use voice activity detection)
`CHANGE_NICKNAME`
`MANAGE_NICKNAMES` (change other members' nicknames)
`MANAGE_ROLES`
`MANAGE_WEBHOOKS`
`MANAGE_EMOJIS`
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "4"

services:
discord-js-bot:
build: .
image: discord-js-bot:latest
container_name: discord-js-bot
restart: unless-stopped
networks:
- lavalink-net
depends_on:
- lavalink
volumes:
- ./*:/usr/src/app/config.js:ro

lavalink:
image: fredboat/lavalink:dev
container_name: music-lavalink
hostname: lavalink
restart: unless-stopped
networks:
- lavalink-net
volumes:
- ./application.yml:/opt/Lavalink/application.yml:ro

networks:
lavalink-net:
11 changes: 11 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:16-alpine

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

CMD [ "node", "index.js" ]
2 changes: 1 addition & 1 deletion src/commands/admin/maxwarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = {
}

if (sub === "action") {
response = await setAction(interaction.options.getString("action"), data.settings);
response = await setAction(interaction.guild, interaction.options.getString("action"), data.settings);
}

await interaction.followUp(response);
Expand Down
3 changes: 2 additions & 1 deletion src/commands/giveaways/sub/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
* @param {number} duration
* @param {string} prize
* @param {number} winners
* @param {import('discord.js').User} host
* @param {import('discord.js').User} [host]
* @param {string[]} [allowedRoles]
*/
module.exports = async (member, giveawayChannel, duration, prize, winners, host, allowedRoles = []) => {
try {
if (!host) host = member.user;
if (!member.permissions.has("MANAGE_MESSAGES")) {
return "You need to have the manage messages permissions to start giveaways.";
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/information/leaderboard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { MessageEmbed } = require("discord.js");
const { MessageEmbed, Util } = require("discord.js");
const { EMBED_COLORS } = require("@root/config");
const { getInvitesLb } = require("@schemas/Member");
const { getXpLb } = require("@schemas/MemberStats");
Expand Down Expand Up @@ -71,7 +71,7 @@ async function getXpLeaderboard({ guild }, author, settings) {
for (let i = 0; i < lb.length; i++) {
try {
const user = await author.client.users.fetch(lb[i].member_id);
collector += `**#${(i + 1).toString()}** - ${user.tag}\n`;
collector += `**#${(i + 1).toString()}** - ${Util.escapeInlineCode(user.tag)}\n`;
} catch (ex) {
// Ignore
}
Expand Down Expand Up @@ -99,7 +99,7 @@ async function getInviteLeaderboard({ guild }, author, settings) {
if (memberId === "VANITY") collector += `**#${(i + 1).toString()}** - Vanity URL [${lb[i].invites}]\n`;
else {
const user = await author.client.users.fetch(lb[i].member_id);
collector += `**#${(i + 1).toString()}** - ${user.tag} [${lb[i].invites}]\n`;
collector += `**#${(i + 1).toString()}** - ${Util.escapeInlineCode(user.tag)} [${lb[i].invites}]\n`;
}
} catch (ex) {
collector += `**#${(i + 1).toString()}** - DeletedUser#0000 [${lb[i].invites}]\n`;
Expand Down
4 changes: 3 additions & 1 deletion src/commands/information/shared/guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ module.exports = async (guild) => {
return members.filter((m) => m.roles.cache.has(role.id)).size;
};

const rolesString = roles.cache
let rolesString = roles.cache
.filter((r) => !r.name.includes("everyone"))
.map((r) => `${r.name}[${getMembersInRole(memberCache, r)}]`)
.join(", ");

if (rolesString.length > 1024) rolesString = rolesString.substring(0, 1020) + "...";

let { verificationLevel } = guild;
switch (guild.verificationLevel) {
case "VERY_HIGH":
Expand Down
4 changes: 3 additions & 1 deletion src/utils/ticketUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ async function openTicket(guild, user, config) {
];

if (config.support_roles.length > 0) {
config.support_roles.forEach((role) => {
config.support_roles.forEach((roleId) => {
const role = guild.roles.cache.get(roleId);
if (!role) return;
permissionOverwrites.push({
id: role,
allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "READ_MESSAGE_HISTORY"],
Expand Down

0 comments on commit ef4aa02

Please sign in to comment.