kylerchin / adorabot

Detected the use of variables before they are defined JS-0357
Anti-pattern
Major
7 occurrences in this check
'cassandraclient' was used before it was defined
 59      //logger.discordInfoLogger.info("Inserted Vote from Top.gg into database", {"type": "VoteWebhookDatabase"})
 60  });
 61
 62  await cassandraclient.execute("INSERT INTO adoravotes.pendingvotereminders (time, userid, service, sent) VALUES (?,?,?,?)", 63  [timeuuid, userid, service, false])
 64  .then((results) => {
 65
'cassandraclient' was used before it was defined
 53  var params;
 54      params = [timeuuid, service, userid];
 55
 56  await cassandraclient.execute(query, params, { prepare: true }, await function (err) { 57      console.log(err);
 58      //Inserted in the cluster
 59      //logger.discordInfoLogger.info("Inserted Vote from Top.gg into database", {"type": "VoteWebhookDatabase"})
'cassandraclient' was used before it was defined
 38     }).catch(error => console.error(error));
 39
 40         //Goes inside adoravotes keyspace, makes the table "pendingreminders"
 41         await cassandraclient.execute("CREATE TABLE IF NOT EXISTS adoravotes.pendingvotereminders (time timeuuid PRIMARY KEY, userid text, service text, sent boolean);") 42         .then(async result => {
 43             await logger.discordDebugLogger.debug({ type: "cassandraclient", result: result })
 44             /*console.log(result)*/
'cassandraclient' was used before it was defined
 31    }).catch(error => console.error(error));
 32
 33     //Goes inside adoravotes keyspace, makes the table "votes"
 34     await cassandraclient.execute("CREATE TABLE IF NOT EXISTS adoravotes.votes (time timeuuid PRIMARY KEY, voteservice text, userid text);") 35     .then(async result => {
 36         await logger.discordDebugLogger.debug({ type: "cassandraclient", result: result })
 37         /*console.log(result)*/
'cassandraclient' was used before it was defined
 24console.log(webhook)
 25
 26async function createDatabases() {
 27    await cassandraclient.execute("CREATE KEYSPACE IF NOT EXISTS adoravotes WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy',  'datacenter1': 1  };") 28    .then(async result => {
 29        await logger.discordDebugLogger.debug({ type: "cassandraclient", result: result })
 30        /*console.log(result)*/
'firstchangedbyidfirststate' was used before it was defined
 596                        if (isBanRecordNew) {
 597                            params = [individualUserIdToAddToBanDatabase, true, reasonForBanRegister, banFirstChangedByIdInitialState, banFirstChangedTimeInitialState, banFirstChangedByIdInitialState, banFirstChangedTimeInitialState];
 598                        } else {
 599                            params = [individualUserIdToAddToBanDatabase, true, reasonForBanRegister, message.author.id, TimeUuid.now(), firstchangedbyidfirststate, firstchangedtimefirststate]; 600                        }
 601
 602                        await cassandraclient.execute(query, params, { prepare: true }, await function (err) {
'firstchangedtimefirststate' was used before it was defined
 596                        if (isBanRecordNew) {
 597                            params = [individualUserIdToAddToBanDatabase, true, reasonForBanRegister, banFirstChangedByIdInitialState, banFirstChangedTimeInitialState, banFirstChangedByIdInitialState, banFirstChangedTimeInitialState];
 598                        } else {
 599                            params = [individualUserIdToAddToBanDatabase, true, reasonForBanRegister, message.author.id, TimeUuid.now(), firstchangedbyidfirststate, firstchangedtimefirststate]; 600                        }
 601
 602                        await cassandraclient.execute(query, params, { prepare: true }, await function (err) {