Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Commit

Permalink
Update 7.1.0
Browse files Browse the repository at this point in the history
## Update List

- [x] Fixed voiceStateUpdate.js
- [x] Add Setup.js
- [x] Revamp Control.js
- [x] Fixed rename all `PermissionsBitField` has change on v14
- [x] Fixed etc. (idk i can't remember)
  • Loading branch information
Adivise committed Sep 9, 2022
1 parent 6a40a09 commit bc43ba5
Show file tree
Hide file tree
Showing 27 changed files with 763 additions and 153 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [x] Music System
- [x] Playlists System
- [x] Premium System
- [x] Song Request System
- [x] Custom Prefix
- [x] Multi Language
- [x] Custom Filters
Expand Down
68 changes: 68 additions & 0 deletions commands/Premium/Setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const { EmbedBuilder, AttachmentBuilder, PermissionsBitField } = require('discord.js');
const Setup = require("../../settings/models/Setup.js");

module.exports = {
config: {
name: "setup",
description: "Setup song request channel!",
accessableby: "Member",
category: "Premium",
},
run: async (client, message, args, user, language, prefix) => {
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageGuild)) return message.channel.send(`${client.i18n.get(language, "utilities", "lang_perm")}`);
try {
if (user && user.isPremium) {
await message.guild.channels.create({
name: "song-request",
type: 0, // 0 = text, 2 = voice
topic: `${client.i18n.get(language, "setup", "setup_topic")}`,
parent_id: message.channel.parentId,
user_limit: 3,
rate_limit_per_user: 3,
}).then(async (channel) => {

const attachment = new AttachmentBuilder("./settings/images/banner.png", { name: "setup.png" });

const queueMsg = `${client.i18n.get(language, "setup", "setup_queuemsg")}`;

const playEmbed = new EmbedBuilder()
.setColor(client.color)
.setAuthor({ name: `${client.i18n.get(language, "setup", "setup_playembed_author")}` })
.setImage(`${client.i18n.get(language, "setup", "setup_playembed_image")}`)
.setDescription(`${client.i18n.get(language, "setup", "setup_playembed_desc")}`)
.setFooter({ text: `${client.i18n.get(language, "setup", "setup_playembed_footer", {
prefix: client.prefix
})}` });

await channel.send({ files: [attachment] });
await channel.send({ content: `${queueMsg}`, embeds: [playEmbed], components: [client.diSwitch] }).then(async (playmsg) => {
await Setup.findOneAndUpdate({ guild: message.guild.id }, {
guild: message.guild.id,
enable: true,
channel: channel.id,
playmsg: playmsg.id,
});
const embed = new EmbedBuilder()
.setDescription(`${client.i18n.get(language, "setup", "setup_msg", {
channel: channel,
})}`)
.setColor(client.color);

return message.channel.send({ embeds: [embed] });
})
});
} else {
const embed = new EmbedBuilder()
.setAuthor({ name: `${client.i18n.get(language, "nopremium", "premium_author")}`, iconURL: client.user.displayAvatarURL() })
.setDescription(`${client.i18n.get(language, "nopremium", "premium_desc")}`)
.setColor(client.color)
.setTimestamp()

return message.channel.send({ content: " ", embeds: [embed] });
}
} catch (err) {
console.log(err)
message.channel.send({ content: `${client.i18n.get(language, "nopremium", "premium_error")}` })
}
}
};
52 changes: 21 additions & 31 deletions commands/Utilities/Control.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { EmbedBuilder } = require('discord.js');
const { EmbedBuilder, PermissionsBitField } = require('discord.js');
const GControl = require('../../settings/models/Control.js');

module.exports = {
config: {
name: "control",
Expand All @@ -10,43 +11,32 @@ module.exports = {
accessableby: "Members"
},
run: async (client, message, args, user, language, prefix) => {
if (!message.member.permissions.has('MANAGE_GUILD')) return message.channel.send(`${client.i18n.get(language, "utilities", "control_perm")}`);
if(!args[0]) return message.channel.send(`${client.i18n.get(language, "utilities", "control_arg")}`);
if(args[0] !== 'enable' && args[0] !== 'disable') return message.channel.send(`${client.i18n.get(language, "utilities", "control_invaild")}`);
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageGuild)) return message.channel.send(`${client.i18n.get(language, "utilities", "control_perm")}`);

const db = await GControl.findOne({ guild: message.guild.id });
if (db.enable) {
db.enable = false;
db.save();

const guildControl = await GControl.findOne({ guild: message.guild.id });
if(!guildControl) {
const guildControl = new GControl({
guild: message.guild.id,
playerControl: args[0]
});
guildControl.save().then(() => {
const embed = new EmbedBuilder()
const embed = new EmbedBuilder()
.setDescription(`${client.i18n.get(language, "utilities", "control_set", {
playerControl: args[0]
playerControl: "Disabled"
})}`)
.setColor(client.color)

message.channel.send({ embeds: [embed] });
}
).catch(() => {
message.channel.send(`${client.i18n.get(language, "utilities", "control_error")}`);
});
}
else if(guildControl) {
guildControl.playerControl = args[0];
guildControl.save().then(() => {
const embed = new EmbedBuilder()
.setDescription(`${client.i18n.get(language, "utilities", "control_change", {
playerControl: args[0]
message.channel.send({ embeds: [embed] });

} else {
db.enable = true;
db.save();

const embed = new EmbedBuilder()
.setDescription(`${client.i18n.get(language, "utilities", "control_set", {
playerControl: "Enabled"
})}`)
.setColor(client.color)

message.channel.send({ embeds: [embed] });
}
).catch(() => {
message.channel.send(`${client.i18n.get(language, "utilities", "control_error")}`);
});

message.channel.send({ embeds: [embed] });
}
}
}
7 changes: 3 additions & 4 deletions commands/Utilities/Language.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { EmbedBuilder } = require('discord.js');
const { EmbedBuilder, PermissionsBitField } = require('discord.js');
const GLang = require('../../settings/models/Language.js');

module.exports = {
Expand All @@ -11,9 +11,8 @@ module.exports = {
accessableby: "Members"
},
run: async (client, message, args, user, language, prefix) => {

if (!message.member.permissions.has('MANAGE_GUILD')) return message.channel.send(`${client.i18n.get(language, "utilities", "lang_perm")}`);
if(!args[0]) return message.channel.send(`${client.i18n.get(language, "utilities", "lang_arg")}`);
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageGuild)) return message.channel.send(`${client.i18n.get(language, "utilities", "lang_perm")}`);
if (!args[0]) return message.channel.send(`${client.i18n.get(language, "utilities", "lang_arg")}`);
const languages = client.i18n.getLocales();
if (!languages.includes(args[0])) return message.channel.send(`${client.i18n.get(language, "utilities", "provide_lang", {
languages: languages.join(', ')
Expand Down
5 changes: 2 additions & 3 deletions commands/Utilities/Prefix.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { EmbedBuilder } = require('discord.js');
const { EmbedBuilder, PermissionsBitField } = require('discord.js');
const GPrefix = require('../../settings/models/Prefix.js');

module.exports = {
Expand All @@ -11,8 +11,7 @@ module.exports = {
accessableby: "Members"
},
run: async (client, message, args, user, language, prefix) => {

if (!message.member.permissions.has('MANAGE_GUILD')) return message.channel.send(`${client.i18n.get(language, "utilities", "prefix_perm")}`);
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageGuild)) return message.channel.send(`${client.i18n.get(language, "utilities", "prefix_perm")}`);
if(!args[0]) return message.channel.send(`${client.i18n.get(language, "utilities", "prefix_arg")}`);
if(args[0].length > 10) return message.channel.send(`${client.i18n.get(language, "utilities", "prefix_length")}`);

Expand Down
4 changes: 2 additions & 2 deletions events/client/error.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { white, red } = require('chalk');

module.exports = async (client) => {
console.log(white('[') + red('WARN') + white('] ') + red('Errored ') + white(`${client.user.tag} (${client.user.id})`) + red(' '));
module.exports = async (client, error) => {
console.log(white('[') + red('WARN') + white('] ') + red('Errored ') + white(`${client.user.tag} (${client.user.id}) | ${error}`) + red(' '));
};
21 changes: 21 additions & 0 deletions events/guild/channelDelete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Setup = require("../../settings/models/Setup.js");

module.exports = async (client, channel) => {
if (channel.type == 2) {
if (channel.members.has(client.user.id)) {
const player = client.manager.players.get(channel.guild.id);
if (!player) return;
if (channel.id === player.voiceChannel) {
player.destroy();
}
}
}

if (channel.type == 0) {
const db = await Setup.findOne({ guild: channel.guild.id });
if (db.channel == channel.id) {
db.enable = false;
await db.save();
}
}
};
155 changes: 155 additions & 0 deletions events/guild/interactionCreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
const { EmbedBuilder } = require("discord.js");
const GLang = require("../../settings/models/Language.js");
const Setup = require("../../settings/models/Setup.js");

module.exports = async (client, interaction) => {
if (!interaction.guild || interaction.user.bot) return;
if (interaction.isButton()) {
const { customId, member } = interaction;
let voiceMember = interaction.guild.members.cache.get(member.id);
let channel = voiceMember.voice.channel;

let player = await client.manager.get(interaction.guild.id);
if (!player) return;

const playChannel = client.channels.cache.get(player.textChannel);
if (!playChannel) return;

let guildModel = await GLang.findOne({ guild: playChannel.guild.id });
if (!guildModel) { guildModel = await GLang.create({
guild: playChannel.guild.id,
language: "en",
});
}

const { language } = guildModel;

const db = await Setup.findOne({ guild: playChannel.guild.id });
if (db.enable === false) return;

// Here delete interaction.reply!
setTimeout(() => interaction.deleteReply(), 4000);

switch (customId) {
case "sprevious":
{
if (!channel) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_voice")}`);
} else if (interaction.guild.members.me.voice.channel && !interaction.guild.members.me.voice.channel.equals(channel)) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_voice")}`);
} else if (!player || !player.queue.previous) {
return interaction.reply(`${client.i18n.get(language, "music", "previous_notfound")}`);
} else {
await player.queue.unshift(player.queue.previous);
await player.stop();

const embed = new EmbedBuilder()
.setDescription(`${client.i18n.get(language, "music", "previous_msg")}`)
.setColor(client.color);

interaction.reply({ embeds: [embed] });
}
}
break;

case "sskip":
{
if (!channel) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_voice")}`);
} else if (interaction.guild.members.me.voice.channel && !interaction.guild.members.me.voice.channel.equals(channel)) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_voice")}`);
} else if (!player) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_player")}`);
} else {}
if (player.queue.size == 0) {
await player.destroy();
await client.UpdateMusic(player);

const embed = new EmbedBuilder()
.setDescription(`${client.i18n.get(language, "music", "skip_msg")}`)
.setColor(client.color);

interaction.reply({ embeds: [embed] });
} else {
await player.stop();

const embed = new EmbedBuilder()
.setDescription(`${client.i18n.get(language, "music", "skip_msg")}`)
.setColor(client.color);

interaction.reply({ embeds: [embed] });
}
}
break;

case "sstop":
{
if (!channel) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_voice")}`);
} else if (interaction.guild.members.me.voice.channel && !interaction.guild.members.me.voice.channel.equals(channel)) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_voice")}`);
} else if (!player) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_player")}`);
} else {
await player.destroy();
await client.UpdateMusic(player);

const embed = new EmbedBuilder()
.setDescription(`${client.i18n.get(language, "player", "stop_msg")}`)
.setColor(client.color);

interaction.reply({ embeds: [embed] });
}
}
break;

case "spause":
{
if (!channel) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_voice")}`);
} else if (interaction.guild.members.me.voice.channel && !interaction.guild.members.me.voice.channel.equals(channel)) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_voice")}`);
} else if (!player) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_player")}`);
} else {
await player.pause(!player.paused);
const uni = player.paused ? `${client.i18n.get(language, "player", "switch_pause")}` : `${client.i18n.get(language, "player", "switch_resume")}`;

const embed = new EmbedBuilder()
.setDescription(`${client.i18n.get(language, "player", "pause_msg", {
pause: uni,
})}`)
.setColor(client.color);

interaction.reply({ embeds: [embed] });
}
}
break;

case "sloop":
{
if (!channel) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_voice")}`);
} else if (interaction.guild.members.me.voice.channel && !interaction.guild.members.me.voice.channel.equals(channel)) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_voice")}`);
} else if (!player) {
return interaction.reply(`${client.i18n.get(language, "noplayer", "no_player")}`);
} else {
await player.setQueueRepeat(!player.queueRepeat);
const uni = player.queueRepeat ? `${client.i18n.get(language, "player", "switch_enable")}` : `${client.i18n.get(language, "player", "switch_disable")}`;

const embed = new EmbedBuilder()
.setDescription(`${client.i18n.get(language, "player", "repeat_msg", {
loop: uni,
})}`)
.setColor(client.color);

interaction.reply({ embeds: [embed] });
}
}
break;
default:
break;
}
}
}
Loading

0 comments on commit bc43ba5

Please sign in to comment.