added "none" argument

This commit is contained in:
Neko Life 2021-05-16 08:43:31 +00:00
parent bcfdb975d7
commit 2dbcccc337
3 changed files with 15 additions and 9 deletions

3
.gitignore vendored
View file

@ -50,6 +50,7 @@ web_modules/
# TypeScript cache
*.tsbuildinfo
*.sqlite3
# Optional npm cache directory
.npm
@ -118,3 +119,5 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
settings.sqlite3
settings.sqlite3

View file

@ -115,9 +115,11 @@ module.exports = class mute extends commando.Command {
const found = findChannelRegEx(msg, key);
logChannel = found[0];
}
if (logChannel) {
theSettingUp.logChannel = logChannel.id;
resultMsg += `Log channel set to: **${logChannel.name}**\n`;
if (/^none$/.test(key)) {
logChannel = undefined;
}
if (logChannel || /^none$/.test(key)) {
theSettingUp.logChannel = logChannel?.id;
} else {
resultMsg += `No channel found for: **${argument}**\n`;
}
@ -130,11 +132,13 @@ module.exports = class mute extends commando.Command {
role = msg.guild.roles.cache.get(argument);
} else {
const found = findRoleRegEx(msg, key);
role = found[0].id;
role = found[0]?.id;
}
if (role) {
if (/^none$/.test(key)) {
role = undefined;
}
if (role || /^none$/.test(key)) {
theSettingUp.role = role;
resultMsg += `Mute role set to: **${role.name}**\n`;
} else {
resultMsg += `No role found for: **${argument}**\n`;
}
@ -193,7 +197,6 @@ module.exports = class mute extends commando.Command {
settingDurationHasSet = true;
theSettingUp.defaultDuration.date = elapsedTime,
theSettingUp.defaultDuration.string = timeForMessage.join(" ");
resultMsg += `Default Duration set to: **${theSettingUp.defaultDuration.string}**\n`;
}
}
if (settingUp) {
@ -218,7 +221,7 @@ module.exports = class mute extends commando.Command {
.addField("Role", roleDoc ? "<@&"+roleDoc+">" : "Not set")
.addField("Duration", defaultDurationDoc?.string ?? "Not set")
.addField("Log", logChannelDoc ? "<#"+logChannelDoc+">" : "Not set");
return trySend(this.client, msg, settings);
return trySend(this.client, msg, {content:resultMsg, embed:settings});
}
for (const usermention of mentions) {
if (usermention.length > 0) {

View file

@ -43,7 +43,7 @@ module.exports = class avatar extends commando.Command {
if (ops.toLowerCase().startsWith("show")) {
const val = ops.trim().split(/ +/);
const theVal = val[1]?.match(/\d*/);
if (theVal[0]) {
if (theVal?.[0]) {
show = parseInt(theVal[0].trim(), 10);
}
}