Merge branch 'devbot' into discordjs-v14-upgrade
This commit is contained in:
commit
9784676e06
10 changed files with 205 additions and 69 deletions
|
@ -15,7 +15,7 @@ module.exports = {
|
|||
.setTimestamp()
|
||||
.setAuthor({name: client.user.username, iconURL: client.user.avatarURL({ dynamic: true, size: 4096 })})
|
||||
.addFields({
|
||||
name: "General info", value: `Name: ${client.user.username}\nPrefix: ${prefix}\nTotal Servers: ${guildCount}\nCreation Date: ${getCreationDate(client)}\nSource: [Click Here](https://github.com/SileNce5k/discord_bot)`,
|
||||
name: "General info", value: `Name: ${client.user.username}\nPrefix: ${prefix}\nTotal Servers: ${guildCount}\nTotal Commands: ${client.commands.size}\nCreation Date: ${getCreationDate(client)}\nSource: [Click Here](https://github.com/SileNce5k/discord_bot)`,
|
||||
},)
|
||||
|
||||
message.channel.send({embeds :[embed]})
|
||||
|
|
|
@ -6,7 +6,7 @@ const getSubdirFiles = require('../../util/getSubdirFiles');
|
|||
module.exports = {
|
||||
name: 'help',
|
||||
description: 'List all available commands.',
|
||||
moreHelp: ["Examples:","`<prefix>help` will return help with a small description for each command",
|
||||
moreHelp: ["Examples:","`<prefix>help [optional_page]` will return help with a small description for each command",
|
||||
"`<prefix>help <another_command>` will return help with a more descriptive description",
|
||||
"The descriptive description isn't available on all commands",
|
||||
"`<prefix>help netmodules` to display help for netmodules"
|
||||
|
@ -15,15 +15,29 @@ module.exports = {
|
|||
let commands = ""
|
||||
let commandFiles = getSubdirFiles('commands/')
|
||||
let x = false;
|
||||
let fieldName = "General";
|
||||
let fieldName = `Page [[page]]/${Math.round(client.commands.size / 10)}`;
|
||||
let iteration = 0;
|
||||
let num_in_args = false;
|
||||
let added_commands = 0;
|
||||
let page = -1;
|
||||
if (args[0] == "netmodules") {
|
||||
commandFiles = fs.readdirSync('../../netload').filter(file => file.endsWith('.js'));
|
||||
if (commandFiles.length == 0) {
|
||||
message.channel.send("There are no netmodules currently loaded.")
|
||||
x = true;
|
||||
}
|
||||
|
||||
|
||||
}else if(!isNaN(parseInt(args[0])) && parseInt(args[0])){
|
||||
num_in_args = true;
|
||||
iteration = ( parseInt(args[0]) - 1) * 10;
|
||||
page = Math.round(parseInt(args[0]))
|
||||
}
|
||||
if(page === -1){
|
||||
page = 1;
|
||||
}
|
||||
fieldName = fieldName.replace("[[page]]", page);
|
||||
const max_commands = iteration + 10;
|
||||
|
||||
if (x) return;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
|
@ -32,16 +46,27 @@ module.exports = {
|
|||
.setTimestamp()
|
||||
.setAuthor({name: client.user.username, iconURL: client.user.avatarURL({ dynamic: true, size: 4096 })})
|
||||
|
||||
let start = 0;
|
||||
|
||||
for (const file of commandFiles) {
|
||||
if(iteration >= max_commands) break;
|
||||
const command = require(`../../${file}`);
|
||||
|
||||
if(command.disabled) continue;
|
||||
|
||||
if (args[0] == "admin") {
|
||||
if (command.admin)
|
||||
commands = commands + `${prefix}${command.name} | ${command.description}\n`
|
||||
}else if(!args[0]){
|
||||
if (!command.admin)
|
||||
commands = commands + `${prefix}${command.name} | ${command.description}\n`
|
||||
}else if(!args[0] || num_in_args){
|
||||
if (!command.admin){
|
||||
if(start < iteration){
|
||||
}else{
|
||||
added_commands++
|
||||
commands = commands + `${prefix}${command.name} | ${command.description}\n`;
|
||||
iteration++
|
||||
}
|
||||
start++;
|
||||
}
|
||||
}else if(args[0] === command.name){
|
||||
commands = commands + `${prefix}${command.name}\n`
|
||||
embed.setTitle(command.name.charAt(0).toUpperCase() + command.name.slice(1))
|
||||
|
@ -65,6 +90,10 @@ module.exports = {
|
|||
embed.addFields(
|
||||
{ name: fieldName, value: commands },
|
||||
)
|
||||
if(embed.fields[0].value.length > 1023){
|
||||
message.channel.send(`There are more than 1023 characters`)
|
||||
}else {
|
||||
message.channel.send({embeds :[embed]});
|
||||
}
|
||||
},
|
||||
};
|
|
@ -1,25 +1,41 @@
|
|||
const fmlogin = require("../../util/lastfm/fmlogin");
|
||||
const displayCurrentScrobble = require("../../util/lastfm/displayCurrentScrobble");
|
||||
|
||||
const getCurrentScrobble = require("../../util/lastfm/getCurrentScrobble");
|
||||
const getTopTracks = require("../../util/lastfm/getTopTracks");
|
||||
const help = require("../info/help");
|
||||
module.exports = {
|
||||
name: 'fm',
|
||||
description: 'Last fm commands. See `<prefix>help fm` for more info.',
|
||||
moreHelp: ["Set username: `<prefix>fm set <lastfm_username>`",],
|
||||
async execute({ message, args }) {
|
||||
let sendText = "Something went wrong.";
|
||||
moreHelp: ["Info: Having a space between fm and the subcommand makes no difference.",
|
||||
"They behave the same (for example: `<prefix>fmtt` and `<prefix>fm tt`)",
|
||||
"Set username: `<prefix>fmset <lastfm_username>`",
|
||||
"Get current scrobble: `<prefix>fm`",
|
||||
"Get top tracks: `<prefix>fmtt`"
|
||||
],
|
||||
async execute({ message, args, prefix, client }) {
|
||||
let sendText = {text: "Something went wrong.", embed: null};
|
||||
switch (args[0]) {
|
||||
case "help":
|
||||
sendText = this.moreHelp;
|
||||
break;
|
||||
help.execute({ message: message, args: ["fm"], prefix: prefix, client: client });
|
||||
return;
|
||||
case "set":
|
||||
sendText = await fmlogin(message.author.id, args[1]);
|
||||
sendText.text = await fmlogin(message.author.id, args[1]);
|
||||
break;
|
||||
case "toptracks":
|
||||
case "tt":
|
||||
args.shift();
|
||||
sendText.text = await getTopTracks(message.author.id, args);
|
||||
break;
|
||||
default:
|
||||
sendText.text = `${args[0]} is not a valid subcommand.\nSee \`${prefix}help fm\` for more info.`;
|
||||
break;
|
||||
}
|
||||
if(args.length < 1){
|
||||
sendText = await displayCurrentScrobble(message.author.id);
|
||||
sendText = await getCurrentScrobble(message.author.id, message.guild);
|
||||
}
|
||||
if(sendText.embed != null){
|
||||
message.channel.send({embeds :[sendText.embed]})
|
||||
}else{
|
||||
message.channel.send(sendText.text);
|
||||
}
|
||||
message.channel.send(sendText);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue