Skip to content

Commit

Permalink
Merge pull request #186 from saiteja-madha/v5.0.1-release
Browse files Browse the repository at this point in the history
V5.0.1 release
  • Loading branch information
saiteja-madha authored Sep 26, 2022
2 parents d8b4095 + 6e05bc4 commit 14cef22
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 122 deletions.
8 changes: 6 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
node_modules
npm-debug.log
.DS_Store
node_modules/
.vscode/
*.log
*.tar.gz
.env
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.DS_Store
.vscode/
node_modules/
logs/*
*.log
*.tar.gz
.env
10 changes: 0 additions & 10 deletions .npmignore

This file was deleted.

12 changes: 11 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,17 @@ module.exports = {
ENABLED: false,
IDLE_TIME: 60, // Time in seconds before the bot disconnects from the voice channel
MAX_SEARCH_RESULTS: 5,
NODES: [],
// Add any number of lavalink nodes here
// Refer to https://github.com/freyacodes/Lavalink to host your own lavalink server
NODES: [
{
host: "localhost",
port: 2333,
password: "youshallnotpass",
identifier: "Local Node",
secure: false,
},
],
},

GIVEAWAYS: {
Expand Down
39 changes: 19 additions & 20 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# Table of contents

* [🤖 About Me](../README.md)
* [📘 Commands](commands/README.md)
* [⚙ Admin](commands/admin.md)
* [🔞 Anime](commands/anime.md)
* [🪙 Economy](commands/economy.md)
* [😂 Fun](commands/fun.md)
* [🎉 Giveaways](commands/giveaways.md)
* [🖼 Image](commands/image.md)
* [🪧 Information](commands/information.md)
* [📨 Invites](commands/invites.md)
* [🔨 Moderation](commands/moderation.md)
* [🎵 Music](commands/music.md)
* [🔏 Owner](commands/owner.md)
* [🧑 Social](commands/social.md)
* [📈 Stats](commands/stats.md)
* [🛠 Utility](commands/utility.md)
* [🗒 Contexts](contexts.md)
- [🤖 About Me](../README.md)
- [📘 Commands](commands/README.md)
- [⚙ Admin](commands/admin.md)
- [🔞 Anime](commands/anime.md)
- [🪙 Economy](commands/economy.md)
- [😂 Fun](commands/fun.md)
- [🎉 Giveaways](commands/giveaways.md)
- [🖼 Image](commands/image.md)
- [🪧 Information](commands/information.md)
- [📨 Invites](commands/invites.md)
- [🔨 Moderation](commands/moderation.md)
- [🎵 Music](commands/music.md)
- [🔏 Owner](commands/owner.md)
- [🧑 Social](commands/social.md)
- [📈 Stats](commands/stats.md)
- [🛠 Utility](commands/utility.md)
- [🗒 Contexts](contexts.md)

## Additional

* [✍ Guides](additional/installation.md)
* [Replit](additional/replit.md)
* [❓ FAQ](additional/faq.md)
- [✍ Guides](additional/installation.md)
- [❓ FAQ](additional/faq.md)
10 changes: 5 additions & 5 deletions docs/additional/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

### Setting up Slash Commands

* Slash commands are disabled by default
* In the **config.js** set **SLASH = true** and **CONTEXT = true** and replace TEST\_GUILD\_ID with the guild ID where you want to initially test the commands. This will ensure that all the commands are registered immediately
* Once you are happy with the commands, set **GLOBAL = true** to register these interactions globally
- Slash commands are disabled by default
- In the **config.js** set **SLASH = true** and **CONTEXT = true** and replace TEST_GUILD_ID with the guild ID where you want to initially test the commands. This will ensure that all the commands are registered immediately
- Once you are happy with the commands, set **GLOBAL = true** to register these interactions globally

{% hint style="warning" %}
_**Global slash commands** can take upto 1 hour to be shown across all guilds_
{% endhint %}

### Setting up Dashboard

* In the config.js, make sure you set dashboard enabled to **true**
* Add your baseURL, `http://localhost:8080/api/callback` in your application OAuth2 redirects page in the [discord developer portal](https://discord.com/developers/applications)
- In the config.js, make sure you set dashboard enabled to **true**
- Add your baseURL, `http://localhost:8080/api/callback` in your application OAuth2 redirects page in the [discord developer portal](https://discord.com/developers/applications)

```
DASHBOARD: {
Expand Down
58 changes: 0 additions & 58 deletions docs/additional/replit.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/contexts.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# 🗒 Contexts

1 change: 0 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"baseUrl": "./",
"paths": {
"@root/*": ["./*"],
"@features/*": ["./src/features/*"],
"@handlers/*": ["./src/handlers/*"],
"@helpers/*": ["./src/helpers/*"],
"@schemas/*": ["./src/database/schemas/*"],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord-js-bot",
"version": "5.0.0",
"version": "5.0.1",
"description": "An open-source, multipurpose discord bot built using discord-js",
"main": "bot.js",
"author": "Sai Teja M",
Expand Down
6 changes: 5 additions & 1 deletion src/commands/admin/automod/anti.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ module.exports = {
if (sub == "ghostping") response = await antiGhostPing(settings, interaction.options.getString("status"));
else if (sub == "spam") response = await antiSpam(settings, interaction.options.getString("status"));
else if (sub === "massmention") {
response = await antiMassMention(settings, interaction.options.getInteger("amount"));
response = await antiMassMention(
settings,
interaction.options.getString("status"),
interaction.options.getInteger("amount")
);
} else response = "Invalid command usage!";

await interaction.followUp(response);
Expand Down
18 changes: 13 additions & 5 deletions src/commands/giveaways/giveaway.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,13 @@ async function runModalSetup({ member, channel, guild }, targetCh) {
new ButtonBuilder().setCustomId("giveaway_btnSetup").setLabel("Setup Giveaway").setStyle(ButtonStyle.Primary)
);

const sentMsg = await channel.send({
const sentMsg = await channel.safeSend({
content: "Please click the button below to setup new giveaway",
components: [buttonRow],
});

if (!sentMsg) return;

const btnInteraction = await channel
.awaitMessageComponent({
componentType: ComponentType.Button,
Expand Down Expand Up @@ -393,12 +395,18 @@ async function runModalSetup({ member, channel, guild }, targetCh) {
modal.fields
.getTextInputValue("roles")
?.split(",")
?.filter((roleId) => guild.roles.cache.get(roleId)) || [];
?.filter((roleId) => guild.roles.cache.get(roleId.trim())) || [];

// host
const host = modal.fields.getTextInputValue("host")
? await guild.client.users.fetch(modal.fields.getTextInputValue("host"))
: null;
const hostId = modal.fields.getTextInputValue("host");
let host = null;
if (hostId) {
try {
host = await guild.client.users.fetch(hostId);
} catch (ex) {
return modal.editReply("Setup has been cancelled. You need to provide a valid userId for host");
}
}

const response = await start(member, targetCh, duration, prize, winners, host, allowedRoles);
await modal.editReply(response);
Expand Down
5 changes: 3 additions & 2 deletions src/commands/moderation/timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ module.exports = {
},
};

async function timeout(issuer, target, minutes, reason) {
const response = await timeoutTarget(issuer, target, minutes, reason);
async function timeout(issuer, target, ms, reason) {
if (!NaN(Number(ms))) return "Please provide a valid duration. Example: 1d/1h/1m/1s";
const response = await timeoutTarget(issuer, target, ms, reason);
if (typeof response === "boolean") return `${target.user.tag} is timed out!`;
if (response === "BOT_PERM") return `I do not have permission to timeout ${target.user.tag}`;
else if (response === "MEMBER_PERM") return `You do not have permission to timeout ${target.user.tag}`;
Expand Down
4 changes: 3 additions & 1 deletion src/commands/ticket/ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,13 @@ async function ticketModalSetup({ guild, channel, member }, targetChannel, setti
new ButtonBuilder().setCustomId("ticket_btnSetup").setLabel("Setup Message").setStyle(ButtonStyle.Primary)
);

const sentMsg = await channel.send({
const sentMsg = await channel.safeSend({
content: "Please click the button below to setup ticket message",
components: [buttonRow],
});

if (!sentMsg) return;

const btnInteraction = await channel
.awaitMessageComponent({
componentType: ComponentType.Button,
Expand Down
3 changes: 2 additions & 1 deletion src/events/guild/guildCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const { getSettings: registerGuild } = require("@schemas/Guild");
* @param {import('discord.js').Guild} guild
*/
module.exports = async (client, guild) => {
if (!guild.members.cache.has(guild.ownerId)) await guild.fetchOwner({ cache: true });
if (!guild.available) return;
if (!guild.members.cache.has(guild.ownerId)) await guild.fetchOwner({ cache: true }).catch(() => {});
client.logger.log(`Guild Joined: ${guild.name} Members: ${guild.memberCount}`);
await registerGuild(guild);

Expand Down
22 changes: 11 additions & 11 deletions src/handlers/automod.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const shouldModerate = (message) => {
const { member, guild, channel } = message;

// Ignore if bot cannot delete channel messages
if (!channel.permissionsFor(guild.members.me).has("ManageMessages")) return false;
if (!channel.permissionsFor(guild.members.me)?.has("ManageMessages")) return false;

// Ignore Possible Guild Moderators
if (member.permissions.has(["KickMembers", "BanMembers", "ManageGuild"])) return false;
Expand Down Expand Up @@ -171,15 +171,15 @@ async function performAutomod(message, settings) {
// send automod log
if (logChannel) {
const logEmbed = new EmbedBuilder()
.setAuthor({ name: "Auto Moderation" })
.setThumbnail(author.displayAvatarURL())
.setColor(AUTOMOD.LOG_EMBED)
.addFields(fields)
.setDescription(`**Channel:** ${channel.toString()}\n**Content:**\n${content}`)
.setFooter({
text: `By ${author.tag} | ${author.id}`,
iconURL: author.avatarURL(),
});
.setAuthor({ name: "Auto Moderation" })
.setThumbnail(author.displayAvatarURL())
.setColor(AUTOMOD.LOG_EMBED)
.addFields(fields)
.setDescription(`**Channel:** ${channel.toString()}\n**Content:**\n${content}`)
.setFooter({
text: `By ${author.tag} | ${author.id}`,
iconURL: author.avatarURL(),
});

logChannel.safeSend({ embeds: [logEmbed] });
}
Expand All @@ -195,7 +195,7 @@ async function performAutomod(message, settings) {
`**Guild:** ${guild.name}\n` +
`**Total Strikes:** ${memberDb.strikes} out of ${automod.strikes}`
);

author.send({ embeds: [strikeEmbed] }).catch((ex) => {});

// check if max strikes are received
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/extenders/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Message.prototype.safeReply = async function (content, seconds) {

perms.push("ReadMessageHistory");
if (this.channel.type !== "DM" && !this.channel.permissionsFor(this.guild.members.me).has(perms)) {
return this.safeSend(content, seconds);
return this.channel.safeSend(content, seconds);
}

try {
Expand Down
1 change: 1 addition & 0 deletions src/structures/BotClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = class BotClient extends Client {
restRequestTimeout: 20000,
});

this.wait = require("util").promisify(setTimeout); // await client.wait(1000) - Wait 1 second
this.config = require("@root/config"); // load the config file

/**
Expand Down

0 comments on commit 14cef22

Please sign in to comment.