Skip to content

Commit

Permalink
Version 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Fear committed Mar 10, 2022
1 parent 52af7ae commit 9bd91c7
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 385 deletions.
33 changes: 0 additions & 33 deletions DscCommands/deploy.js

This file was deleted.

33 changes: 0 additions & 33 deletions DscCommands/dis-reload.js

This file was deleted.

52 changes: 0 additions & 52 deletions DscCommands/eval.js

This file was deleted.

69 changes: 0 additions & 69 deletions DscCommands/help.js

This file was deleted.

19 changes: 0 additions & 19 deletions DscCommands/mylevel.js

This file was deleted.

35 changes: 0 additions & 35 deletions DscCommands/reboot.js

This file was deleted.

31 changes: 0 additions & 31 deletions DscCommands/stats.js

This file was deleted.

2 changes: 1 addition & 1 deletion DscEvents/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = async (client, interaction) => {
// This will basically set the ephemeral response to either announce
// to everyone, or just the command executioner. But we **HAVE** to
// respond.
ephemeral: settings.systemNotice !== "true"
ephemeral: "true"
});
}

Expand Down
74 changes: 2 additions & 72 deletions DscEvents/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,17 @@ module.exports = async (client, message) => {
if (message.author.bot) return;
if (message.webhookId) return;

// Grab the settings for this server from Enmap.
// If there is no guild, get default conf (DMs)
const settings = config.defaultSettings;


// Checks if the bot was mentioned via regex, with no message after it,
// returns the prefix. The reason why we used regex here instead of
// message.mentions is because of the mention prefix later on in the
// code, would render it useless.
const prefixMention = new RegExp(`^<@!?${client.user.id}> ?$`);
if (message.content.match(prefixMention)) {
return message.reply(`My prefix on this guild is \`${settings.prefix}\``);
return message.reply(`This bot's commands can be used by slash commands`);
}

// It's also good practice to ignore any and all messages that do not start
// with our prefix, or a bot mention.
const prefix = new RegExp(`^<@!?${client.user.id}> |^\\${settings.prefix}`).exec(message.content);
// If it's not a command, treat it as a relay if it matches our relay channel.
if (!prefix){
// If it is a relay channel for Main

config.relays.forEach (async (value, key) => {
if (value === message.channel.id) {
Expand All @@ -50,66 +42,4 @@ module.exports = async (client, message) => {
}

})





}else{
// Here we separate our "command" name, and our "arguments" for the command.
// e.g. if we have the message "+say Is this the real life?" , we'll get the following:
// command = say
// args = ["Is", "this", "the", "real", "life?"]
const args = message.content.slice(prefix[0].length).trim().split(/ +/g);
const command = args.shift().toLowerCase();

// If the member on a guild is invisible or not cached, fetch them.
if (message.guild && !message.member) await message.guild.members.fetch(message.author);

// Get the user or member's permission level from the elevation
const level = permlevel(message);

// Check whether the command, or alias, exist in the collections defined
// in app.js.
const cmd = container.commands.get(command) || container.commands.get(container.aliases.get(command));
// using this const varName = thing OR otherThing; is a pretty efficient
// and clean way to grab one of 2 values!
if (!cmd) return;

// Some commands may not be useable in DMs. This check prevents those commands from running
// and return a friendly error message.
if (cmd && !message.guild && cmd.conf.guildOnly)
return message.channel.send("This command is unavailable via private message. Please run this command in a guild.");

if (!cmd.conf.enabled) return;

if (level < container.levelCache[cmd.conf.permLevel]) {
if (settings.systemNotice === "true") {
return message.channel.send(`You do not have permission to use this command.
Your permission level is ${level} (${config.permLevels.find(l => l.level === level).name})
This command requires level ${container.levelCache[cmd.conf.permLevel]} (${cmd.conf.permLevel})`);
} else {
return;
}
}

// To simplify message arguments, the author's level is now put on level (not member so it is supported in DMs)
// The "level" command module argument will be deprecated in the future.
message.author.permLevel = level;

message.flags = [];
while (args[0] && args[0][0] === "-") {
message.flags.push(args.shift().slice(1));
}
// If the command exists, **AND** the user has permission, run it.
try {
await cmd.run(client, message, args, level);
logger.log(`${config.permLevels.find(l => l.level === level).name} ${message.author.id} ran command ${cmd.help.name}`, "cmd");
} catch (e) {
console.error(e);
message.channel.send({ content: `There was a problem with your request.\n\`\`\`${e.message}\`\`\`` })
.catch(e => console.error("An error occurred replying on an error", e));
}

}
};
2 changes: 1 addition & 1 deletion DscEvents/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module.exports = async client => {
logger.log(`${client.user.tag}, ready to serve ${client.guilds.cache.map(g => g.memberCount).reduce((a, b) => a + b)} users in ${client.guilds.cache.size} servers.`, "ready");

// Make the bot "play the game" which is the help command with default prefix.
client.user.setActivity(`Tagteaming SL and Discord`, { type: "PLAYING" });
client.user.setActivity(`with the Metaverse`, { type: "PLAYING" });
};
Loading

0 comments on commit 9bd91c7

Please sign in to comment.