@ -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 ) +