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

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