Skip to content

Commit 7eebf67

Browse files
authored
Merge pull request #24 from BrayanbotDev/dev
merge dev branch into main
2 parents cd0492b + 7c5205b commit 7eebf67

File tree

9 files changed

+493
-445
lines changed

9 files changed

+493
-445
lines changed

Events/ready.js

Lines changed: 68 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,82 @@
1-
const { REST } = require("@discordjs/rest"),
2-
{ Routes } = require("discord-api-types/v9"),
3-
Discord = require("discord.js"),
4-
Utils = require("../Modules/Utils"),
5-
packageJSON = require("../package.json"),
6-
fsUtils = require("nodejs-fs-utils"),
1+
const { REST } = require("@discordjs/rest"), { Routes } = require("discord-api-types/v9"),
2+
Discord = require("discord.js"), Utils = require("../Modules/Utils"),
3+
packageJSON = require("../package.json"), fsUtils = require("nodejs-fs-utils"),
74
chalk = require("chalk");
5+
86
/**
97
*
108
* @param {Discord.Client} bot
119
* @param {Discord.Interaction} interaction
1210
*/
1311
module.exports = async (bot) => {
14-
let { SlashCmds, SlashCmdsData, config } = bot;
15-
16-
await Utils.logInfo(
17-
"#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#"
18-
);
19-
await Utils.logInfo(
20-
" "
21-
);
22-
await Utils.logInfo(
23-
` • ${chalk.bold(
24-
`Brayan Bot v${packageJSON.version}`
25-
)} is now Online! • `
26-
);
27-
await Utils.logInfo(
28-
" "
29-
);
30-
await Utils.logInfo(
31-
" • Join our Discord Server for any Issues/Custom Bots • "
32-
);
33-
await Utils.logInfo(
34-
` ${chalk.blue(
35-
chalk.underline(`https://discord.gg/EgeZxGg6ev`)
36-
)} `
37-
);
38-
await Utils.logInfo(
39-
" "
40-
);
41-
await Utils.logInfo(
42-
"#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#"
43-
);
44-
45-
let fSize = fsUtils.fsizeSync('./', {
46-
skipErrors: true,
47-
countFolders: true
48-
})
12+
let { SlashCmds, SlashCmdsData, config } = bot,
13+
rest = new REST({ version: "9" }).setToken(config.Settings.Token),
14+
fSize = fsUtils.fsizeSync('./', {
15+
skipErrors: true,
16+
countFolders: true
17+
}), guild = bot.guilds.cache.first();
4918

19+
await Utils.logInfo("#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#");
20+
await Utils.logInfo(" ");
21+
await Utils.logInfo(` • ${chalk.bold(`Brayan Bot v${packageJSON.version}`)} is now Online! • `);
22+
await Utils.logInfo(" ");
23+
await Utils.logInfo(" • Join our Discord Server for any Issues/Custom Bots • ");
24+
await Utils.logInfo(` ${chalk.blue(chalk.underline(`https://discord.gg/EgeZxGg6ev`))} `);
25+
await Utils.logInfo(" ");
26+
await Utils.logInfo("#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#");
5027
await Utils.logInfo(`${chalk.bold(bot.Commands.size)} Command${bot.Commands.size == 1 ? "" : "s"} Loaded.`);
5128
await Utils.logInfo(`${chalk.bold(bot.Events.length)} Event${bot.Events.length == 1 ? "" : "s"} Loaded.`);
52-
const rest = new REST({ version: "9" }).setToken(config.Settings.Token);
53-
SlashCmdsData = SlashCmdsData.filter((x) => typeof x == "object");
54-
try {
55-
await rest.put(
56-
Routes.applicationGuildCommands(
57-
bot.user.id,
58-
config.Settings.ServerID
59-
),
60-
{
61-
body: SlashCmdsData,
29+
30+
await rest.put(Routes.applicationGuildCommands(bot.user.id, guild.id), {
31+
body: SlashCmdsData.filter((x) => typeof x == "object"),
32+
}).then(async registredCommands => {
33+
let fullPermissions = [];
34+
for (let index = 0; index < registredCommands.length; index++) {
35+
let element = registredCommands[index],
36+
commandYMLData = SlashCmds.find(x => x.name.toLowerCase() == element.name.toLowerCase()),
37+
cmdPerms = [];
38+
if (!commandYMLData.commandData.Permission.includes("@everyone")) {
39+
for (let i = 0; i < commandYMLData.commandData.Permission.length; i++) {
40+
const element2 = commandYMLData.commandData.Permission[i];
41+
if (element2.toLowerCase() !== "@everyone") {
42+
let role = await Utils.findRole(element2, guild, true)
43+
if (role) {
44+
cmdPerms.push({
45+
id: role.id,
46+
type: "ROLE",
47+
permission: true
48+
})
49+
}
50+
}
51+
}
52+
fullPermissions.push({
53+
id: element.id,
54+
permissions: cmdPerms
55+
})
56+
} else {
57+
fullPermissions.push({
58+
id: element.id,
59+
permissions: [
60+
{
61+
id: guild.id,
62+
type: "ROLE",
63+
permission: true
64+
}
65+
]
66+
})
6267
}
63-
);
64-
await Utils.logInfo(
65-
`${chalk.bold(SlashCmdsData.length)} Slash Command${SlashCmdsData.length == 1 ? "" : "s"} Loaded.`
66-
);
67-
} catch (error) {
68-
console.log(error);
69-
Utils.logError(error);
70-
}
68+
}
69+
await guild.commands.permissions.set({ fullPermissions })
70+
await Utils.logInfo(`${chalk.bold(SlashCmdsData.length)} Slash Command${SlashCmdsData.length == 1 ? "" : "s"} Loaded.`);
71+
}).catch(e => {
72+
if (e.code == 50001) {
73+
Utils.logWarning(`[SlashCommands] \"${chalk.bold(`application.commands`)}\" scope wasn't selected while inviting the bot. Please use the below link to re-invite your bot.`)
74+
Utils.logWarning(`[SlashCommands] ${chalk.blue(chalk.underline(chalk.bold(`https://discord.com/api/oauth2/authorize?client_id=${bot.user.id}&permissions=8&scope=bot%20applications.commands`)))}`)
75+
} else {
76+
Utils.logError(e);
77+
}
78+
})
79+
7180

7281
await Utils.logInfo(`Logged in as: ${chalk.bold(bot.user.tag)}`);
7382
await Utils.logInfo(`Currently using ${chalk.bold(Utils.bytesToSize(fSize))} of storage`);

Modules/Utils/parseSlashCommand.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = (data) => {
4444
name: undefined,
4545
description: undefined,
4646
options: [],
47-
default_permission: undefined,
47+
default_permission: false,
4848
};
4949
if (!Name) Utils.logError(`[Utils] [SlashCommandCreator] A ${chalk.bold("Name")} is required to build Slash Command.`);
5050
if (!Description) Utils.logError(`[Utils] [SlashCommandCreator] A ${chalk.bold("Description")} is required to build Slash Command.`);

Modules/Utils/setupMessage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ module.exports = (settings, ephemeral = false, components = null) => {
112112
Thumbnail = settings.thumbnail || embedSettings.thumbnail || embedSettings.Thumbnail,
113113
Author = settings.author || embedSettings.author || embedSettings.Author,
114114
AuthorAvatarImage = settings.authoricon || embedSettings.authoricon || embedSettings.AuthorIcon,
115-
Color = settings.icon || embedSettings.color || embedSettings.Color || config.Embeds.Color || "2f3136",
115+
Color = settings.color || embedSettings.color || embedSettings.Color || config.Embeds.Color || "2f3136",
116116
Fields = settings.fields || embedSettings.fields || embedSettings.Fields,
117117
Image = settings.image || embedSettings.image || embedSettings.Image,
118118
URL = settings.url || embedSettings.url || embedSettings.URL,

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ Current Addon Developers:
3434

3535
BrayanBot is driven by the awesome community of third-party developers, which makes it more functional and enjoyable for everyone. If you are looking into building your own Add-ons for Brayan, consider looking into the documentation to get started!
3636

37-
Need help? Join our [Discord Server](https://discord.gg/EgeZxGg6ev)!
37+
Need help? Join our [Discord Server](https://brayanbot.dev/discord)!
3838

3939
## ✨ Contributing
4040

4141
Contributions of any kind are welcome! Please feel free to submit them to the repository via pull requests.
4242

43-
<a href="https://github.com/DakshNamdev/BrayanBot/graphs/contributors">
44-
<img src="https://contributors-img.web.app/image?repo=DakshNamdev/BrayanBot" width="150"/>
43+
<a href="https://github.com/BrayanbotDev/BrayanBot/graphs/contributors">
44+
<img src="https://contributors-img.web.app/image?repo=BrayanbotDev/BrayanBot" width="150"/>
4545
</a>

commands.yml

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
11
DisabledCommands: []
22
General:
3-
Help:
3+
Help:
4+
Description: "Displays all Bot Commands"
5+
Usage: "help"
6+
Aliases: []
7+
Permission:
8+
- "@everyone"
9+
SlashCommand:
10+
Enabled: true
11+
Data:
12+
Name: help
413
Description: "Displays all Bot Commands"
5-
Usage: "help"
6-
Aliases: []
7-
Permission:
8-
- "@everyone"
9-
SlashCommand:
10-
Enabled: true
11-
Data:
12-
Name: help
13-
Description: "Displays all Bot Commands"
14-
Options:
15-
- Type: "string"
16-
Name: "command"
17-
Description: "Command for info"
18-
Ping:
14+
Options:
15+
- Type: "string"
16+
Name: "command"
17+
Description: "Command for info"
18+
Ping:
19+
Description: "Displays Bot Pings"
20+
Usage: "ping"
21+
Aliases: []
22+
Permission:
23+
- "@everyone"
24+
SlashCommand:
25+
Enabled: true
26+
Data:
27+
Name: ping
1928
Description: "Displays Bot Pings"
20-
Usage: "ping"
21-
Aliases: []
22-
Permission:
23-
- "@everyone"
24-
SlashCommand:
25-
Enabled: true
26-
Data:
27-
Name: ping
28-
Description: "Displays Bot Pings"
29-
Uptime:
29+
Uptime:
30+
Description: "View Your Bot's Current Uptime"
31+
Usage: "uptime"
32+
Aliases: []
33+
Permission:
34+
- "@everyone"
35+
SlashCommand:
36+
Enabled: true
37+
Data:
38+
Name: uptime
3039
Description: "View Your Bot's Current Uptime"
31-
Usage: "uptime"
32-
Aliases: []
33-
Permission:
34-
- "@everyone"
35-
SlashCommand:
36-
Enabled: true
37-
Data:
38-
Name: uptime
39-
Description: "View Your Bot's Current Uptime"
40-
ServerInfo:
40+
ServerInfo:
41+
Description: "View Server's Information"
42+
Usage: "serverinfo"
43+
Aliases:
44+
- "guildinfo"
45+
Permission:
46+
- "@everyone"
47+
SlashCommand:
48+
Enabled: true
49+
Data:
50+
Name: serverinfo
4151
Description: "View Server's Information"
42-
Usage: "serverinfo"
43-
Aliases:
44-
- "guildinfo"
45-
Permission:
46-
- "@everyone"
47-
SlashCommand:
48-
Enabled: true
49-
Data:
50-
Name: serverinfo
51-
Description: "View Server's Information"
52-
Avatar:
52+
Avatar:
53+
Description: "Displays user's avatar"
54+
Usage: "avatar <user>"
55+
Aliases:
56+
- "av"
57+
Permission:
58+
- "@everyone"
59+
SlashCommand:
60+
Enabled: true
61+
Data:
62+
Name: avatar
5363
Description: "Displays user's avatar"
54-
Usage: "avatar <user>"
55-
Aliases:
56-
- "av"
57-
Permission:
58-
- "@everyone"
59-
SlashCommand:
60-
Enabled: true
61-
Data:
62-
Name: avatar
63-
Description: "Displays user's avatar"
64-
Options:
65-
- Type: "User"
66-
Name: "target"
67-
Description: "User Mention"
64+
Options:
65+
- Type: "User"
66+
Name: "target"
67+
Description: "User Mention"

example.config.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
Settings:
2-
Token: "BOT-TOKEN"
3-
Prefix: "-"
4-
ServerID: "YOUR-SERVER-ID"
5-
Storage: "database.db"
6-
DevMode: false # This option will reset every addon configs.
2+
Token: "BOT-TOKEN"
3+
Prefix: "-"
4+
Storage: "database.db"
5+
DevMode: false # This option will reset every addon configs.
76

87
Embeds:
9-
Branding: "Brayan Bot"
10-
Color: "2f3136"
8+
Branding: "Brayan Bot"
9+
Color: "2f3136"
1110

1211
Misc:
13-
Version: "v1.0.0"
12+
Version: "v1.0.0"

install/setup.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const config =
1313
"Color": "2f3136"
1414
},
1515
"Misc": {
16-
"Version" : "v1.0.0",
16+
"Version": "v1.0.0",
1717
},
1818
}
1919

@@ -75,13 +75,6 @@ function doSetup() {
7575
// message: 'Must be a - , _ , or !'
7676
required: false,
7777
},
78-
serverId: {
79-
description: `Your Server ID.`,
80-
type: 'integer',
81-
default: config.Settings.ServerID,
82-
required: true,
83-
message: 'You must input a valid server ID.'
84-
},
8578
storage: {
8679
description: `Name of your storage file. (Example: ${config.Settings.Storage})`,
8780
type: 'string',

0 commit comments

Comments
 (0)