jillo-bot/src/commands/change.ts

99 lines
3.2 KiB
TypeScript

import { SlashCommandBuilder } from '@discordjs/builders';
import { CategoryChannel, CommandInteraction, GuildMember, MessageEmbed, TextChannel } from 'discord.js';
const rand = [
'This change has no significance.',
'You do not know what this can do.',
'Nothing has changed.',
'Nothing of value has been changed.',
'You\'ll want to find something of value to change next time.'
];
const names = [
'Fire\'s Pit',
'Flaming Pit',
'Pit of Fire',
'Pit Fire',
'Pire Fit',
'White Space',
'The void',
'Fire pit',
'fire pit'
];
const channels = [
'toyota',
'ъ',
'deadlocked',
'stereo-madness',
'basketball',
'send-help'
];
const nicknames = [
'напиток безалкогольный сильногаз',
'forg',
'foggy',
'frog',
'fog'
];
module.exports = {
data: new SlashCommandBuilder()
.setName('change')
.setDescription('Change')
.addStringOption((option) => option.setName('what').setDescription('Change what? Examples include: "environment", "perspective", etc...').setRequired(true)),
execute: async (interaction: CommandInteraction, member: GuildMember) => {
const what = interaction.options.getString('what')!;
let title = `**${member.displayName}** changed the **${what}**`;
let response;
switch (what.toLowerCase()) {
case 'environment':
case 'surroundings': {
const name = names[Math.floor(Math.random() * names.length)];
response = `You feel as if you're in a new space entirely. You find yourself in **${name}**.`;
await interaction.guild!.setName(name, 'environment change');
break;
}
case 'perspective':
case 'vision': {
const channel = channels[Math.floor(Math.random() * channels.length)];
response = `You've decided you want to change your perspective on the place you find yourself in. You are now in **#${channel}**.`;
await (interaction.channel as TextChannel).setName(channel);
break;
}
case 'persona':
case 'self':
title = 'I\'m afraid I can\'t do that.';
response = `You're locked in as is, **${member.user.username}**. Noone but you can change this.`;
break;
case 'identity':
response = 'I\'ve changed my nickname in accordance. I hope this identity pleases you.';
await interaction.guild!.me!.setNickname(nicknames[Math.floor(Math.random() * nicknames.length)]);
break;
case 'location':
case 'position': {
response = 'You do not feel like your surroundings have changed, but rather where you are relative to your surroundings has changed.';
const categories = Array(...interaction.guild!.channels.cache.filter(v => v.type === 'GUILD_CATEGORY').values());
const category = categories[Math.floor(Math.random() * categories.length)] as CategoryChannel;
await (interaction.channel as TextChannel).setParent(category);
await (interaction.channel as TextChannel).setPosition(Math.floor(Math.random() * category.children.size));
break;
}
default:
response = rand[Math.floor(Math.random() * rand.length)];
}
const embed = new MessageEmbed()
.setTitle(title)
.setDescription(response)
.setTimestamp();
await interaction.reply({
embeds: [embed],
ephemeral: false,
});
}
};