aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-25 14:47:07 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-25 14:47:07 -0400
commit0af0be5ab4ea0d972d9c406b28b81ee41a06cbdb (patch)
treecb5d6f06a115d7e9c3d38ea44995161f6c158082 /src/commands
parent76622cfcd13727949ef3a0baa30bf72007132cd2 (diff)
downloadtanzanite-0af0be5ab4ea0d972d9c406b28b81ee41a06cbdb.tar.gz
tanzanite-0af0be5ab4ea0d972d9c406b28b81ee41a06cbdb.tar.bz2
tanzanite-0af0be5ab4ea0d972d9c406b28b81ee41a06cbdb.zip
join roles, sticky roles, join messages, support threads etc
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/config/autoPublishChannel.ts3
-rw-r--r--src/commands/config/features.ts23
-rw-r--r--src/commands/config/joinRoles.ts54
-rw-r--r--src/commands/moderation/ban.ts4
-rw-r--r--src/commands/utilities/viewraw.ts51
5 files changed, 99 insertions, 36 deletions
diff --git a/src/commands/config/autoPublishChannel.ts b/src/commands/config/autoPublishChannel.ts
index f058402..10c4ab6 100644
--- a/src/commands/config/autoPublishChannel.ts
+++ b/src/commands/config/autoPublishChannel.ts
@@ -46,6 +46,9 @@ export default class AutoPublishChannelCommand extends BushCommand {
channel.id
);
await message.guild!.setSetting('autoPublishChannels', newValue);
+ client.logger.debugRaw(autoPublishChannels);
+ client.logger.debugRaw(channel.id);
+ client.logger.debugRaw(autoPublishChannels.includes(channel.id));
return await message.util.reply({
content: `${util.emojis.success} Successfully ${
autoPublishChannels.includes(channel.id) ? 'disabled' : 'enabled'
diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts
index d37ce25..cb7f4bc 100644
--- a/src/commands/config/features.ts
+++ b/src/commands/config/features.ts
@@ -14,16 +14,31 @@
// slash: true,
// channel: 'guild',
// clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'],
-// userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD']
+// userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'],
+// ownerOnly: true
// });
// }
// public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> {
// if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`);
-// const featureEmbed = new MessageEmbed().setTitle(`${message.guild.name}'s Features`).setColor(util.colors.default);
+// const featureEmbed = await this.generateEmbed(message);
+// return await message.util.reply({ embeds: [featureEmbed] });
+// }
+
+// public async handleInteraction(): Promise<void> {
+
+// }
+
+// public async generateEmbed(message: BushMessage | BushSlashMessage): Promise<MessageEmbed> {
+// const featureEmbed = new MessageEmbed().setTitle(`${message.guild!.name}'s Features`).setColor(util.colors.default);
// const featureList: string[] = [];
-// const enabledFeatures = await message.guild.getSetting('enabledFeatures');
+// const enabledFeatures = await message.guild!.getSetting('enabledFeatures');
// guildFeatures.forEach((feature) => {
-// // featureList.push(`**${feature}:** ${enabledFeatures.includes(feature)? util.emojis.}`);
+// featureList.push(`**${feature}:** ${enabledFeatures.includes(feature) ? util.emojis.check : util.emojis.cross}`);
// });
+// return featureEmbed.setDescription(featureList.join('\n'));
+// }
+
+// public async generateButtons(): Promise<void>{
+
// }
// }
diff --git a/src/commands/config/joinRoles.ts b/src/commands/config/joinRoles.ts
new file mode 100644
index 0000000..ee2ce75
--- /dev/null
+++ b/src/commands/config/joinRoles.ts
@@ -0,0 +1,54 @@
+import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib';
+import { Channel } from 'discord.js';
+
+export default class JoinRolesCommand extends BushCommand {
+ public constructor() {
+ super('joinRoles', {
+ aliases: ['joinroles', 'joinrole', 'jr'],
+ category: 'config',
+ description: {
+ content: 'Configure what roles to assign to someone when they join the server.',
+ usage: 'joinroles <role>',
+ examples: ['joinroles @member']
+ },
+ args: [
+ {
+ id: 'role',
+ type: 'role',
+ prompt: {
+ start: 'What role would you like me to assign to users when they join the server?',
+ retry: '{error} Choose a valid role',
+ optional: true
+ }
+ }
+ ],
+ slash: true,
+ slashOptions: [
+ {
+ name: 'role',
+ description: 'What role would you like me to assign to users when they join the server?',
+ type: 'ROLE',
+ required: false
+ }
+ ],
+ channel: 'guild',
+ clientPermissions: ['SEND_MESSAGES'],
+ userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD']
+ });
+ }
+ public override async exec(message: BushMessage | BushSlashMessage, { channel }: { channel: Channel }): Promise<unknown> {
+ const autoPublishChannels = await message.guild!.getSetting('joinRoles');
+ const newValue = util.addOrRemoveFromArray(
+ autoPublishChannels.includes(channel.id) ? 'remove' : 'add',
+ autoPublishChannels,
+ channel.id
+ );
+ await message.guild!.setSetting('joinRoles', newValue);
+ return await message.util.reply({
+ content: `${util.emojis.success} Successfully ${
+ autoPublishChannels.includes(channel.id) ? 'disabled' : 'enabled'
+ } auto publishing in <#${channel.id}>.`,
+ allowedMentions: AllowedMentions.none()
+ });
+ }
+}
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index 8a98998..3a86244 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -5,7 +5,7 @@ import { User } from 'discord.js';
export default class BanCommand extends BushCommand {
public constructor() {
super('ban', {
- aliases: ['ban', 'forceban'],
+ aliases: ['ban', 'forceban', 'dban'],
category: 'moderation',
description: {
content: 'Ban a member from the server.',
@@ -99,6 +99,8 @@ export default class BanCommand extends BushCommand {
return message.util.reply(canModerateResponse);
}
+ if (message.util.parsed?.alias === 'dban' && !days) days = 1;
+
if (!Number.isInteger(days) || days! < 0 || days! > 7) {
return message.util.reply(`${util.emojis.error} The delete days must be an integer between 0 and 7.`);
}
diff --git a/src/commands/utilities/viewraw.ts b/src/commands/utilities/viewraw.ts
index bc79b7a..bd185d4 100644
--- a/src/commands/utilities/viewraw.ts
+++ b/src/commands/utilities/viewraw.ts
@@ -1,5 +1,4 @@
-import { DMChannel, Message, MessageEmbed, NewsChannel, Snowflake, TextChannel } from 'discord.js';
-import { inspect } from 'util';
+import { DMChannel, MessageEmbed, NewsChannel, Snowflake, TextChannel } from 'discord.js';
import { BushCommand, BushMessage, BushSlashMessage } from '../../lib';
export default class ViewRawCommand extends BushCommand {
@@ -8,15 +7,16 @@ export default class ViewRawCommand extends BushCommand {
aliases: ['viewraw'],
category: 'utilities',
clientPermissions: ['EMBED_LINKS'],
+ channel: 'guild',
description: {
usage: 'viewraw <message id> <channel>',
examples: ['viewraw 322862723090219008'],
- content: 'Gives information about a specified user.'
+ content: 'Shows raw information about a message.'
},
args: [
{
id: 'message',
- customType: util.arg.union('message', 'bigint'),
+ type: 'snowflake',
prompt: {
start: 'What message would you like to view?',
retry: '{error} Choose a valid message.',
@@ -30,8 +30,7 @@ export default class ViewRawCommand extends BushCommand {
start: 'What channel is the message in?',
retry: '{error} Choose a valid channel.',
optional: true
- },
- default: (m: Message) => m.channel
+ }
},
{
id: 'json',
@@ -49,21 +48,14 @@ export default class ViewRawCommand extends BushCommand {
public override async exec(
message: BushMessage | BushSlashMessage,
- args: { message: Message | BigInt; channel: TextChannel | NewsChannel | DMChannel; json?: boolean; js: boolean }
+ args: { message: Snowflake; channel: TextChannel | NewsChannel | DMChannel; json?: boolean; js: boolean }
): Promise<unknown> {
- let newMessage: Message | 0;
- if (!(typeof args.message === 'object')) {
- newMessage = await args.channel.messages.fetch(`${args.message}` as Snowflake).catch(() => {
- return 0;
- });
- if (!newMessage) {
- return await message.util.reply(
- `${util.emojis.error} There was an error fetching that message, try supplying a channel.`
- );
- }
- } else {
- newMessage = args.message as Message;
- }
+ if (!args.channel) args.channel = (message.channel as TextChannel | NewsChannel | DMChannel)!;
+ const newMessage = await args.channel.messages.fetch(`${args.message}` as Snowflake).catch(() => null);
+ if (!newMessage)
+ return await message.util.reply(
+ `${util.emojis.error} There was an error fetching that message, make sure that is a valid id and if the message is not in this channel, please provide a channel.`
+ );
const messageEmbed = await ViewRawCommand.getRawData(newMessage as BushMessage, { json: args.json, js: args.js });
@@ -74,18 +66,15 @@ export default class ViewRawCommand extends BushCommand {
const content =
options.json || options.js
? options.json
- ? inspect(JSON.stringify(message.toJSON()))
- : inspect(message.toJSON()) || '[No Content]'
+ ? JSON.stringify(message.toJSON(), undefined, 2)
+ : util.inspect(message.toJSON()) || '[No Content]'
: message.content || '[No Content]';
const lang = options.json ? 'json' : options.js ? 'js' : undefined;
- return (
- new MessageEmbed()
- .setFooter(message.author.tag, message.author.avatarURL({ dynamic: true }) ?? undefined)
- .setTimestamp(message.createdTimestamp)
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
- .setColor(message.member?.roles?.color?.color || util.colors.default)
- .setTitle('Raw Message Information')
- .setDescription(await util.codeblock(content, 2048, lang))
- );
+ return new MessageEmbed()
+ .setFooter(message.author.tag, message.author.avatarURL({ dynamic: true }) ?? undefined)
+ .setTimestamp(message.createdTimestamp)
+ .setColor(message.member?.roles?.color?.color ?? util.colors.default)
+ .setTitle('Raw Message Information')
+ .setDescription(await util.codeblock(content, 2048, lang));
}
}