Skip to content

Commit

Permalink
Merge pull request #96 from saiteja-madha/4.1.0-release
Browse files Browse the repository at this point in the history
4.1.0 release
  • Loading branch information
saiteja-madha authored Feb 12, 2022
2 parents 65d3526 + 0b4a717 commit 53ebed0
Show file tree
Hide file tree
Showing 90 changed files with 1,645 additions and 388 deletions.
29 changes: 15 additions & 14 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ module.exports = {
OWNER_IDS: [], // Bot owner ID's
PREFIX: "!", // Default prefix for the bot
SUPPORT_SERVER: "", // Your bot support server
PRESENCE: {
ENABLED: true, // Whether or not the bot should update its status
STATUS: "online", // The bot's status [online, idle, dnd, invisible]
TYPE: "WATCHING", // Status type for the bot [PLAYING | LISTENING | WATCHING | COMPETING]
MESSAGE: "{members} members in {servers} servers", // Your bot status message
},
DASHBOARD: {
enabled: false, // enable or disable dashboard
baseURL: "http://localhost:8080", // base url
Expand All @@ -24,6 +30,8 @@ module.exports = {
ECONOMY: {
CURRENCY: "₪",
DAILY_COINS: 100, // coins to be received by daily command
MIN_BEG_AMOUNT: 100, // minimum coins to be received when beg command is used
MAX_BEG_AMOUNT: 2500, // maximum coins to be received when beg command is used
},
IMAGE: {
BASE_API: "https://image-api.strangebot.xyz",
Expand All @@ -33,19 +41,11 @@ module.exports = {
MAX_SEARCH_RESULTS: 5,
NODES: [
{
host: "disbotlistlavalink.ml",
port: 443,
password: "LAVA",
identifier: "DBL Lavalink",
retryDelay: 3000,
secure: true,
},
{
host: "lava.link",
host: "lavalink.strangebot.xyz",
port: 80,
password: "anything as a password",
identifier: "Something Host",
retryDelay: 3000,
password: "strangebot",
identifier: "Strange Link",
retryDelay: 5000,
secure: false,
},
],
Expand All @@ -60,8 +60,8 @@ module.exports = {
AUTOMOD: "#36393F",
TICKET_CREATE: "#068ADD",
TICKET_CLOSE: "#068ADD",
MUTE_LOG: "#102027",
UNMUTE_LOG: "#4B636E",
TIMEOUT_LOG: "#102027",
UNTIMEOUT_LOG: "#4B636E",
KICK_LOG: "#FF7961",
SOFTBAN_LOG: "#AF4448",
BAN_LOG: "#D32F2F",
Expand All @@ -71,6 +71,7 @@ module.exports = {
UNDEAFEN_LOG: "#4B636E",
DISCONNECT_LOG: "RANDOM",
MOVE_LOG: "RANDOM",
GIVEAWAYS: "#FF468A",
},
/* Maximum number of keys that can be stored */
CACHE_SIZE: {
Expand Down
29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"name": "discord-js-bot",
"version": "4.0.1",
"version": "4.1.0",
"description": "A multipurpose discord bot built using discord-js",
"main": "bot.js",
"author": "Sai Teja M",
"license": "ISC",
"engines": {
"node": ">=16.6.0"
},
"scripts": {
"dev": "nodemon .",
"start": "node ."
Expand All @@ -20,23 +23,23 @@
"btoa": "^1.2.1",
"chalk": "^4.1.2",
"country-language": "^0.1.7",
"discord.js": "^13.3.1",
"dotenv": "^10.0.0",
"discord-giveaways": "^5.0.1",
"discord.js": "^13.6.0",
"dotenv": "^16.0.0",
"ejs": "^3.1.6",
"erela.js": "^2.3.3",
"erela.js-deezer": "^1.0.7",
"erela.js-facebook": "^1.0.4",
"erela.js-spotify": "^1.2.0",
"express": "^4.17.1",
"express": "^4.17.2",
"express-session": "^1.17.2",
"fixedsize-map": "^1.0.1",
"fs": "0.0.2",
"iso-639-1": "^2.1.10",
"fs": "0.0.1-security",
"iso-639-1": "^2.1.12",
"module-alias": "^2.2.2",
"moment": "^2.29.1",
"mongoose": "^5.13.7",
"mongoose-lean-defaults": "^2.0.1",
"nekos.life": "^2.0.7",
"nekos.life": "^2.0.9",
"node-fetch": "^2.6.1",
"os": "^0.1.2",
"outdent": "^0.8.0",
Expand All @@ -45,16 +48,16 @@
"snakecord": "^1.0.9",
"sourcebin_js": "^0.0.3-ignore",
"string-progressbar": "^1.0.4",
"table": "^6.7.3",
"table": "^6.8.0",
"timestamp-to-date": "^1.1.0",
"twemoji-parser": "^13.1.0"
},
"devDependencies": {
"eslint": "^7.32.0",
"eslint-plugin-jsdoc": "^36.0.8",
"eslint": "^8.6.0",
"eslint-plugin-jsdoc": "^37.6.1",
"node": "^16.10.0",
"nodemon": "^2.0.12",
"prettier": "2.3.2"
"nodemon": "^2.0.15",
"prettier": "2.5.1"
},
"keywords": [
"discord",
Expand Down
10 changes: 2 additions & 8 deletions src/commands/admin/automod/automodconfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { Command } = require("@src/structures");
const { getRoleByName } = require("@utils/guildUtils");
const { Message, MessageEmbed, CommandInteraction } = require("discord.js");
const { EMBED_COLORS } = require("@root/config.js");
const { getSettings } = require("@schemas/Guild");
Expand Down Expand Up @@ -216,13 +215,8 @@ async function setStrikes(settings, strikes) {

async function setAction(settings, guild, action) {
if (action === "MUTE") {
let mutedRole = getRoleByName(guild, "muted");
if (!mutedRole) {
return `Muted role doesn't exist in this guild`;
}

if (!mutedRole.editable) {
return "I do not have permission to move members to `Muted` role. Is that role below my highest role?";
if (!guild.me.permissions.has("MODERATE_MEMBERS")) {
return "I do not permission to timeout members";
}
}

Expand Down
118 changes: 118 additions & 0 deletions src/commands/admin/autorole.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
const { Command } = require("@src/structures");
const { getSettings } = require("@schemas/Guild");
const { Message, CommandInteraction } = require("discord.js");
const { findMatchingRoles } = require("@utils/guildUtils");

module.exports = class AutoRole extends Command {
constructor(client) {
super(client, {
name: "autorole",
description: "setup role to be given when a member joins the server",
category: "ADMIN",
userPermissions: ["MANAGE_GUILD"],
command: {
enabled: true,
usage: "<role|off>",
minArgsCount: 1,
},
slashCommand: {
enabled: true,
ephemeral: true,
options: [
{
name: "add",
description: "setup the autorole",
type: "SUB_COMMAND",
options: [
{
name: "role",
description: "the role to be given",
type: "ROLE",
required: false,
},
{
name: "role_id",
description: "the role id to be given",
type: "STRING",
required: false,
},
],
},
{
name: "remove",
description: "disable the autorole",
type: "SUB_COMMAND",
},
],
},
});
}

/**
* @param {Message} message
* @param {string[]} args
*/
async messageRun(message, args) {
const input = args.join(" ");
let response;

if (input.toLowerCase() === "off") {
response = await setAutoRole(message, null);
} else {
const roles = findMatchingRoles(message.guild, input);
if (roles.length === 0) response = "No matching roles found matching your query";
else response = await setAutoRole(message, roles[0]);
}

await message.reply(response);
}

/**
* @param {CommandInteraction} interaction
*/
async interactionRun(interaction) {
const sub = interaction.options.getSubcommand();
let response;

// add
if (sub === "add") {
let role = interaction.options.getRole("role");
if (!role) {
const role_id = interaction.options.getString("role_id");
if (!role_id) return interaction.followUp("Please provide a role or role id");

const roles = findMatchingRoles(interaction.guild, role_id);
if (roles.length === 0) return interaction.followUp("No matching roles found matching your query");
role = roles[0];
}

response = await setAutoRole(interaction, role);
}

// remove
else if (sub === "remove") {
response = await setAutoRole(interaction, null);
}

// default
else response = "Invalid subcommand";

await interaction.followUp(response);
}
};

async function setAutoRole({ guild }, role) {
const settings = await getSettings(guild);

if (role) {
if (!guild.me.permissions.has("MANAGE_ROLES")) return "I don't have the `MANAGE_ROLES` permission";
if (guild.me.roles.highest.position < role.position) return "I don't have the permissions to assign this role";
if (role.managed) return "Oops! This role is managed by an integration";
}

if (!role) settings.autorole = null;
else settings.autorole = role.id;

await settings.save();
return `Configuration saved! Autorole is ${!role ? "disabled" : "setup"}`;
}
14 changes: 7 additions & 7 deletions src/commands/admin/counter-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ module.exports = class CounterSetup extends Command {
* @param {string[]} args
*/
async messageRun(message, args) {
const type = args[0].toLowerCase();
if (!type || !["users", "members", "bots"].includes(type)) {
const type = args[0].toUpperCase();
if (!type || !["USERS", "MEMBERS", "BOTS"].includes(type)) {
return message.reply("Incorrect arguments are passed! Counter types: `users/members/bots`");
}
if (args.length < 2) return message.reply("Incorrect Usage! You did not provide name");
Expand All @@ -75,7 +75,7 @@ module.exports = class CounterSetup extends Command {
const type = interaction.options.getString("type");
const name = interaction.options.getString("name");

const response = await setupCounter(interaction.guild, type, name);
const response = await setupCounter(interaction.guild, type.toUpperCase(), name);
return interaction.followUp(response);
}
};
Expand All @@ -84,9 +84,9 @@ async function setupCounter(guild, type, name) {
let channelName = name;

const stats = await getMemberStats(guild);
if (type.toUpperCase() === "USERS") channelName += ` : ${stats[0]}`;
else if (type.toUpperCase() === "MEMBERS") channelName += ` : ${stats[2]}`;
else if (type.toUpperCase() === "BOTS") channelName += ` : ${stats[1]}`;
if (type === "USERS") channelName += ` : ${stats[0]}`;
else if (type === "MEMBERS") channelName += ` : ${stats[2]}`;
else if (type === "BOTS") channelName += ` : ${stats[1]}`;

const vc = await guild.channels.create(channelName, {
type: "GUILD_VOICE",
Expand All @@ -104,7 +104,7 @@ async function setupCounter(guild, type, name) {

const settings = await getSettings(guild);

const exists = settings.counters.find((v) => v.counter_type === type);
const exists = settings.counters.find((v) => v.counter_type.toUpperCase() === type);
if (exists) {
exists.name = name;
exists.channel_id = vc.id;
Expand Down
10 changes: 2 additions & 8 deletions src/commands/admin/maxwarn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { Command } = require("@src/structures");
const { getSettings } = require("@schemas/Guild");
const { Message, CommandInteraction } = require("discord.js");
const { getRoleByName } = require("@utils/guildUtils");

module.exports = class MaxWarn extends Command {
constructor(client) {
Expand Down Expand Up @@ -126,13 +125,8 @@ async function setLimit(guild, limit) {

async function setAction(guild, action) {
if (action === "MUTE") {
let mutedRole = getRoleByName(guild, "muted");
if (!mutedRole) {
return `Muted role doesn't exist in this guild`;
}

if (!mutedRole.editable) {
return "I do not have permission to move members to `Muted` role. Is that role below my highest role?";
if (!guild.me.permissions.has("MODERATE_MEMBERS")) {
return "I do not permission to timeout members";
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/commands/admin/ticket/ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module.exports = class Ticket extends Command {
{
name: "amount",
description: "max number of tickets",
type: "STRING",
type: "INTEGER",
required: true,
},
],
Expand Down Expand Up @@ -308,9 +308,9 @@ async function runInteractiveSetup({ channel, guild, author }) {
const filter = (m) => m.author.id === author.id;

const embed = new MessageEmbed()
.setAuthor("Ticket Setup")
.setAuthor({ name: "Ticket Setup" })
.setColor(EMBED_COLORS.BOT_EMBED)
.setFooter("Type cancel to cancel setup");
.setFooter({ text: "Type cancel to cancel setup" });

let targetChannel;
let title;
Expand Down Expand Up @@ -369,9 +369,9 @@ async function runInteractiveSetup({ channel, guild, author }) {
async function setupTicket(guild, channel, title, role, color) {
try {
const embed = new MessageEmbed()
.setAuthor("Support Ticket")
.setAuthor({ name: "Support Ticket" })
.setDescription(title)
.setFooter("You can only have 1 open ticket at a time!");
.setFooter({ text: "You can only have 1 open ticket at a time!" });

if (color) embed.setColor(color);

Expand Down
7 changes: 5 additions & 2 deletions src/commands/anime/nsfw.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ const genNSFW = async (category, user) => {
if (!category) category = "randomHentaiGif";
try {
const response = await neko.nsfw[category]();
return new MessageEmbed().setImage(response.url).setColor("RANDOM").setFooter(`Requested by ${user.tag}`);
return new MessageEmbed()
.setImage(response.url)
.setColor("RANDOM")
.setFooter({ text: `Requested by ${user.tag}` });
} catch (ex) {
return new MessageEmbed()
.setColor(EMBED_COLORS.ERROR)
.setDescription("Failed to fetch meme. Try again!")
.setFooter(`Requested by ${user.tag}`);
.setFooter({ text: `Requested by ${user.tag}` });
}
};
Loading

0 comments on commit 53ebed0

Please sign in to comment.