master
Chloe Fontenot 🏳️‍⚧️ 2023-04-05 00:49:38 +07:00
parent 19d65140cc
commit d369ac2d93
7 changed files with 30 additions and 29 deletions

@ -1,5 +1,5 @@
const { SlashCommandBuilder, Discord, codeBlock } = require('discord.js'); const { SlashCommandBuilder, Discord, codeBlock } = require('discord.js');
import { writeFile } from '../main.ts'; //const { writeFile } = require('../main.cjs');
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@ -16,13 +16,13 @@ module.exports = {
.setRequired(true) .setRequired(true)
), ),
async execute(interaction, client) { async execute(interaction, client) {
var inputString = interaction.options.getString('string'); let inputString = interaction.options.getString('string');
var design = parseInt(interaction.options.getString('design')); let design = parseInt(interaction.options.getString('design'));
if (design < 1 || design > 4) { if (design < 1 || design > 4) {
await interaction.reply('Invalid design choice.'); await interaction.reply('Invalid design choice.');
return; return;
} }
var output; let output;
switch (design) { switch (design) {
case 1: case 1:
output = design1(inputString); output = design1(inputString);
@ -38,7 +38,7 @@ module.exports = {
} }
console.log(codeBlock("", output)); console.log(codeBlock("", output));
writeFile(); writeFile();
var testLength = "\n" + 'output length was ' + (output.length) + " characters."; let testLength = "\n" + 'output length was ' + (output.length) + " characters.";
if (output.length + testLength.length > 2000) { if (output.length + testLength.length > 2000) {
await interaction.reply('Error: String is too big. Resultant output would be too big to send to Discord. (the output length was ' + (output.length + testLength.length) + " characters.)"); await interaction.reply('Error: String is too big. Resultant output would be too big to send to Discord. (the output length was ' + (output.length + testLength.length) + " characters.)");
return; return;
@ -47,10 +47,15 @@ module.exports = {
console.log("User " + interaction.user.tag + " ran /drawtriangle"); console.log("User " + interaction.user.tag + " ran /drawtriangle");
}, },
}; };
function writeFile() {
console.log("Write file was called")
}
function design1(input) { function design1(input) {
console.log("Running design1..."); console.log("Running design1...");
var outputString; let outputString;
var startEnd = ""; let startEnd = "";
for (let i = 0; i < input.length + 2; i++) { for (let i = 0; i < input.length + 2; i++) {
startEnd += "*"; startEnd += "*";
} }
@ -63,9 +68,9 @@ function design1(input) {
} }
function design2(input) { function design2(input) {
console.log("Running design2..."); console.log("Running design2...");
var outputString; let outputString;
var height = (input.length * 2) + 6; let height = (input.length * 2) + 6;
var mid = Math.trunc(height / 2) + 1; let mid = Math.trunc(height / 2) + 1;
if (height % 2 == 0) { if (height % 2 == 0) {
height++; height++;
} }
@ -84,9 +89,9 @@ function design2(input) {
} }
function design3(input) { function design3(input) {
console.log("Running design3..."); console.log("Running design3...");
var outputString; let outputString;
var height = (input.length * 2) + 6; let height = (input.length * 2) + 6;
var mid = Math.trunc(height / 2) + 1; let mid = Math.trunc(height / 2) + 1;
if (height % 2 == 0) { if (height % 2 == 0) {
height++; height++;
} }
@ -131,9 +136,9 @@ function design3(input) {
} }
function design4(input) { function design4(input) {
var outputString = ""; let outputString = "";
var radius = input.length +1; let radius = input.length +1;
var mid = radius; let mid = radius;
if (mid % 2 == 1) { if (mid % 2 == 1) {
var spaceOffset = " "; var spaceOffset = " ";
} else { } else {
@ -141,16 +146,16 @@ function design4(input) {
} }
// dist represents distance to the center // dist represents distance to the center
var dist = parseFloat(0); let dist = parseFloat(0);
var space = "" let space = ""
for (let i = 0; i < (input.length / 2); ++i) { for (let i = 0; i < (input.length / 2); ++i) {
space += " "; space += " ";
} }
// for horizontal movement // for horizontal movement
for (var i = 0; i <= 2 * radius; i++) { for (let i = 0; i <= 2 * radius; i++) {
if (i != mid && j != 0) { if (i != mid && j != 0) {
// for vertical movement // for vertical movement
for (var j = 0; j <= 2 * radius; j++) { for (let j = 0; j <= 2 * radius; j++) {
dist = Math.sqrt( dist = Math.sqrt(
(i - radius) * (i - radius) + (i - radius) * (i - radius) +

@ -29,7 +29,7 @@ client.login(token);
client.commands = new Collection(); client.commands = new Collection();
const commandsPath = path.join(__dirname, 'commands'); const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.ts')); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.cjs'));
for (const file of commandFiles) { for (const file of commandFiles) {
const filePath = path.join(commandsPath, file); const filePath = path.join(commandsPath, file);
@ -134,9 +134,9 @@ function checkMessage(message) {
console.log(matchMessageArray); console.log(matchMessageArray);
let correctedMessage = message.content; let correctedMessage = message.content;
let matchDetected = false; let matchDetected = false;
var abbrsUsed = 0; let abbrsUsed = 0;
for (let i = 0; i < matchMessageArray.length; ++i) { for (let i = 0; i < matchMessageArray.length; ++i) {
var rebuildMessageArray = []; let rebuildMessageArray = [];
//console.log("Corrected Message: " + correctedMessage); //console.log("Corrected Message: " + correctedMessage);
if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) { if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) {
@ -147,8 +147,8 @@ function checkMessage(message) {
matchDetected = true; matchDetected = true;
abbrsUsed++; abbrsUsed++;
//Return key //Return key
var phrase = abbreviationKey.target_phrases[matchMessageArray[i]]; let phrase = abbreviationKey.target_phrases[matchMessageArray[i]];
var abbr = matchAbbr(phrase); //abbreviationKey.target_phrases[phrase]; let abbr = matchAbbr(phrase); //abbreviationKey.target_phrases[phrase];
//console.log(typeof(abbr)); //console.log(typeof(abbr));
console.log("Found abbreviation: " + abbr); console.log("Found abbreviation: " + abbr);
@ -213,8 +213,4 @@ function checkInsult(message) {
} }
} }
} }
}
function writeFile() {
console.log("Write file was called!");
} }