Skip to content

Commit

Permalink
v0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
GeckoBoy84 committed Feb 14, 2022
1 parent 90ae489 commit 865eb72
Show file tree
Hide file tree
Showing 14 changed files with 3,607 additions and 107 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PteroControl

This opensource code is currently not recommended for production use as it is not in a stable state. The public bot inviteable [here](https://discord.gg/AMCTzrmRPY) and will receive updates and bug fixes prior to this source code to ensure stability.
50 changes: 50 additions & 0 deletions commands/owner/shutdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const {
Message,
Client,
MessageEmbed
} = require("discord.js");
const wait = require("util").promisify(setTimeout);

module.exports = {
name: "shutdown",
aliases: ['sd'],
permissions: ["ADMINISTRATOR"],
/**
*
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
const ownerIDs = ['INSERT_OWNER_ID_HERE'];
const shutdownembed = new MessageEmbed()
.setTitle("Shutting down")
.setDescription("Bye bye");
if (!ownerIDs.includes(message.author.id)) {

return message.channel.reply({
content: 'You do not have enough permissions to use this command.',
ephemeral: true,
});
}

try {
message.channel.send({
embeds: [shutdownembed]
}).then(msg => {
msg.react('🆗');
message.delete()
wait(5000)
msg.delete()
}).then(() => {
wait(10000)
client.destroy()
process.exit()

});
} catch (e) {
console.log(e);
}

},
};
12 changes: 4 additions & 8 deletions events/guildCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ client.on('guildCreate', async (guild) => {
name: 'PteroControl | Information',
iconURL: client.user.avatarURL(),
})
.setColor('RANDOM')
.setColor('GREEN')
.setThumbnail(guild.iconURL())
.setDescription(

Expand All @@ -57,14 +57,10 @@ client.on('guildCreate', async (guild) => {
},

{
name: 'Owner Name',
value: `${owner.name}`,
},
{
name: 'Owner ID',
value: `${owner.id}`,
name: 'Owner Info',
value: `<@${owner.id}> (${owner.id})`,
},
{
{
name: 'Total Member Count',
value: `${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)}`,
},
Expand Down
35 changes: 32 additions & 3 deletions events/guildDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,46 @@ const client = require('../bot');


client.on('guildDelete', async (guild) => {

const owner = await guild.fetchOwner();
const newEmbed = new MessageEmbed()
.setAuthor({
name: 'PteroControl | Information',
iconURL: client.user.avatarURL(),
})
.setColor('RANDOM')
.setColor('RED')
.setThumbnail(guild.iconURL())
.setDescription(

`I've left a guild:\n\n **${guild.name}**`,
`GUILD REMOVED`,)
.addFields(

{
name: 'Guild Name',
value: `${guild.name}`,
},

{
name: 'Guild ID',
value: `${guild.id}`,
},

{
name: 'Guild Member Count',
value: `${guild.memberCount}`,
},

{
name: 'Owner Info',
value: `<@${owner.id}> (${owner.id})`,
},
{
name: 'Total Member Count',
value: `${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)}`,
},
{
name: 'Total Guilds',
value: `${client.guilds.cache.size}`,
},
);
const loggingchannel = client.channels.cache.get('939844393425317951');
loggingchannel.send({
Expand Down
69 changes: 35 additions & 34 deletions events/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ client.on('interactionCreate', async interaction => {

const cmd = client.slashCommands.get(interaction.commandName);
if (!cmd) {
return interaction.followUp({
return interaction.reply({
content: 'An error has occured ',
});
}

const args = [];

for (const option of interaction.options.data) {
if (option.type === 'SUB_COMMAND') {
if (option.type === '1') {
if (option.name) args.push(option.name);
option.options?.forEach((x) => {
if (x.value) args.push(x.value);
Expand All @@ -40,48 +40,49 @@ client.on('interactionCreate', async interaction => {
return interaction.reply({
embeds: [
new MessageEmbed()
.setColor(ee.embed_color)
.setColor("BLUE")
.setDescription(`You don't Have ${cmd.permissions} To Run Command..`),
],
ephemeral: true,
});
}
cmd.run(client, interaction, args);
const messageChannel = client.channels.cache.get('941049199846379561');
const messageChannel = client.channels.cache.get('941049199846379561');

const embedLog = new MessageEmbed()
.setColor('AQUA')
.setAuthor({
name: `${interaction.user.tag} used slashcommand`,
iconURL: interaction.user.avatarURL({
dynamic: true,
size: 512,
}),
})
const embedLog = new MessageEmbed()
.setColor('AQUA')
.setAuthor({
name: `${interaction.user.tag} used slashcommand`,
iconURL: interaction.user.avatarURL({
dynamic: true,
size: 512,
}),
})

.setDescription(`${interaction.user}`)
.setThumbnail(interaction.user.avatarURL({
dynamic: true,
size: 512,
}))
// .setTimestamp(moment().format('ddd DD-MM-YYYY HH:mm:ss'))
.setFooter({
text: moment().format('ddd DD-MM-YYYY HH:mm:ss'),
})
.addField('**Command**', `${cmd.name}: ` + `${args}`)
.addField('**Can run:**', `${interaction.member.permissions.has(cmd.permissions || [])}`, true)
.addField('**Channel**:', `${interaction.channel}`, true);
.setDescription(`${interaction.user}`)
.setThumbnail(interaction.user.avatarURL({
dynamic: true,
size: 512,
}))
// .setTimestamp(moment().format('ddd DD-MM-YYYY HH:mm:ss'))
.setFooter({
text: moment().format('ddd DD-MM-YYYY HH:mm:ss'),
})
.addField('**Command**', `${cmd.name}: ` + `${args}`)
.addField('**Can run:**', `${interaction.member.permissions.has(cmd.permissions || [])}`, true)
.addField('**Channel**:', `${interaction.channel}`, true)
.addField('**Guild ID**:', `${interaction.guild.id}`, true);

if (cmd.permissions == ' ') {
embedLog.addField('**Permissions**:', 'None', true);
} else {
embedLog.addField('**Permissions**:', `${cmd.permissions}`, true);
}
if (cmd.permissions == ' ') {
embedLog.addField('**Permissions**:', 'None', true);
} else {
embedLog.addField('**Permissions**:', `${cmd.permissions}`, true);
}

messageChannel.send({
embeds: [embedLog],
});
}
messageChannel.send({
embeds: [embedLog],
});
}
}
// Context Menu Handling
if (interaction.isContextMenu()) {
Expand Down
10 changes: 5 additions & 5 deletions handlers/antiCrash.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ module.exports = async (client) => {
console.log(code);
console.log('=== [antiCrash] :: [beforeExit] :: [end] ==='.yellow.dim);
});
process.on('exit', (error) => { // If You Want You Can Use
console.log('=== [antiCrash] :: [exit] :: [start] ==='.yellow.dim);
console.log(error);
console.log('=== [antiCrash] :: [exit] :: [end] ==='.yellow.dim);
});
// process.on('exit', (error) => { // If You Want You Can Use
// console.log('=== [antiCrash] :: [exit] :: [start] ==='.yellow.dim);
// console.log(error);
// console.log('=== [antiCrash] :: [exit] :: [end] ==='.yellow.dim);
// });
process.on('multipleResolves', (type, promise, reason) => { // Needed
console.log('=== [antiCrash] :: [multipleResolves] :: [start] ==='.yellow.dim);
console.log(type, promise, reason);
Expand Down
95 changes: 70 additions & 25 deletions handlers/slash_handler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
const {
REST
} = require('@discordjs/rest');
const {
Routes
} = require('discord-api-types/v9');
const {
TOKEN,
UseGlobal,
clientId,
guildId
} = require('../settings/config.json');

const {
Client
} = require('discord.js');
Expand All @@ -9,35 +22,67 @@ const fs = require('fs');
*/

module.exports = (client) => {
try {
let command = 0;
const arrayOfSlashCommands = [];
fs.readdirSync('./slscommands').forEach(cmd => {
const commands = fs.readdirSync(`./slscommands/${cmd}/`).filter((file) => file.endsWith('.js'));
for (cmds of commands) {
const pull = require(`../slscommands/${cmd}/${cmds}`);
if (pull.name) {
client.slashCommands.set(pull.name, pull);
arrayOfSlashCommands.push(pull);
command++;
} else {
console.log(`${cmds} Command is not Ready`);
continue;
console.log(UseGlobal);
console.log(clientId);
console.log(guildId);

(async () => {
try {
let commandli = 0;
const commands = [];
fs.readdirSync('./slscommands').forEach(async (cmd) => {
const commandFiles = fs.readdirSync(`./slscommands/${cmd}/`).filter((file) => file.endsWith('.js'));
for (cmds of commandFiles) {
const command = require(`../slscommands/${cmd}/${cmds}`);
if (command) {
client.slashCommands.set(command.name, command);
commands.push(command);
commandli++;
} else {
console.log(`${cmds} Command is not Ready`);
continue;
}
}
if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
// client.on('ready', async () => {
// client.guilds.cache.forEach(async (g) => {
// await client.guilds.cache.get(g.id).commands.set(commands);
// });
//
//
// });

}
client.on('ready', async () => {
client.guilds.cache.forEach(async (g) => {
await client.guilds.cache.get(g.id).commands.set(arrayOfSlashCommands);
});
const rest = new REST({
version: '9'
}).setToken(TOKEN);



// console.log('Started refreshing application (/) commands.');
client.logger(`Started refreshing application (/) commands.`.brightGreen);

if (UseGlobal === 'true') {
client.logger('Global application set true'.brightGreen);
await rest.put(
Routes.applicationCommands(clientId), {
body: commands
},
);
} else {
client.logger('Global application set false'.brightGreen);
await rest.put(
Routes.applicationGuildCommands(clientId, guildId), {
body: commands
},
);
}
// console.log('Successfully reloaded application (/) commands.');
client.logger(`Successfully reloaded application (/) commands.✅`.brightGreen);

});
// console.log(`${command} Slashcommands Loaded✅`);
} catch (e) {
console.log(e.message);
}
})();

});
// console.log(`${command} Slashcommands Loaded✅`);
} catch (e) {
console.log(e.message);
}
};
16 changes: 0 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ const manager = new ShardingManager('./bot.js', {
token: config.TOKEN
});

console.log(`
╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ ██████╗░████████╗███████╗██████╗░░█████╗░░█████╗░░█████╗░███╗░░██╗████████╗██████╗░░█████╗░██╗░░░░░ │
│ ██╔══██╗╚══██╔══╝██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔══██╗████╗░██║╚══██╔══╝██╔══██╗██╔══██╗██║░░░░░ │
│ ██████╔╝░░░██║░░░█████╗░░██████╔╝██║░░██║██║░░╚═╝██║░░██║██╔██╗██║░░░██║░░░██████╔╝██║░░██║██║░░░░░ │
│ ██╔═══╝░░░░██║░░░██╔══╝░░██╔══██╗██║░░██║██║░░██╗██║░░██║██║╚████║░░░██║░░░██╔══██╗██║░░██║██║░░░░░ │
│ ██║░░░░░░░░██║░░░███████╗██║░░██║╚█████╔╝╚█████╔╝╚█████╔╝██║░╚███║░░░██║░░░██║░░██║╚█████╔╝███████╗ │
│ ╚═╝░░░░░░░░╚═╝░░░╚══════╝╚═╝░░╚═╝░╚════╝░░╚════╝░░╚════╝░╚═╝░░╚══╝░░░╚═╝░░░╚═╝░░╚═╝░╚════╝░╚══════╝ │
│ │
│ │
│ Support Server - https://discord.gg/AMCTzrmRPY │
│ Website - https://pterocontrol.scarcehost.uk/ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯
`)
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));

manager.spawn();
8 changes: 6 additions & 2 deletions settings/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"Database": "INSERT_MONGO_URL_HERE",
"TOKEN": "INSERT_TOKEN_HERE",
"inviteSupport": "https://discord.gg/jU4fQvhDCz",
"inviteLink": "https://discord.com/api/oauth2/authorize?client_id=939836646914920488&permissions=8&scope=bot%20applications.commands"
}
"inviteLink": "https://discord.com/api/oauth2/authorize?client_id=939836646914920488&permissions=8&scope=bot%20applications.commands",
"UseGlobal": "false",
"clientId": "INSERT_YOUR_BOT_ID_HERE",
"guildId": "INSERT_GUILD_ID_HERE"

}
Loading

0 comments on commit 865eb72

Please sign in to comment.