diff options
| author | ame <[email protected]> | 2024-05-14 14:10:22 -0500 | 
|---|---|---|
| committer | ame <[email protected]> | 2024-05-14 14:10:22 -0500 | 
| commit | 25261521356055e9e2550ca484670ad18d0c49e3 (patch) | |
| tree | 9a4130d88e2ded6db8a9d81c7c8ec03b1db2b18d | |
| parent | 9c8c0fd8126d13b5e48cdfe9c06d738567de6e78 (diff) | |
a
| -rw-r--r-- | commands/util/status.js | 2 | ||||
| -rw-r--r-- | events/member-update.js | 45 | ||||
| -rw-r--r-- | src/db.js | 2 | 
3 files changed, 45 insertions, 4 deletions
| diff --git a/commands/util/status.js b/commands/util/status.js index b64a81b..dc05ab7 100644 --- a/commands/util/status.js +++ b/commands/util/status.js @@ -65,4 +65,4 @@ module.exports = {              message.reply({embeds:[emoteembed],components:[row]})          })      } -}
\ No newline at end of file +} diff --git a/events/member-update.js b/events/member-update.js index 8dcfd9e..d276e16 100644 --- a/events/member-update.js +++ b/events/member-update.js @@ -8,7 +8,7 @@ let config_loc = __filename+".json"  module.exports = {      name : "guildMemberUpdate",      config_loc : config_loc, -    build_message(p, t){ +    _build_message(p, t){          global.channels["general"].messages.fetch({limit : 1}).then(async messages => {              let message = messages.first();              if(message.id == global.notif.id){ @@ -48,6 +48,47 @@ module.exports = {              }          })      }, +    build_message(p, t){ +        let lim = 1; +        let types = { +            voted: {start: "", end: " just voted! You can too by clicking [here](https://discords.com/servers/486957006628847626/upvote)"}, +            joined: {start: "Welcome to the server ", end: "!"}, +        } +        global.channels["general"].messages.fetch({limit : lim}).then(async messages => { +            //console.log(messages) +            let found = false +            let message = null +            for(let m of messages){ +                if(m[0] == global.notif[t+"_id"]){ +                    if(lim == 1) message = m[1]; +                        else { +                        try{ +                            await m[1].delete() +                        } catch(e) { +                            console.log("failed to delete message") +                        } +                    } +                    found = true +                    break +                } +            } +            if(!found) global.notif[t] = [p] +            let con = types[t].start +            for(let i = 0; i != global.notif[t].length - 1; i++){ +                con += "<@"+global.notif[t][i]+">, " +            } +            if(global.notif[t].length > 1) con += "and " +            con += "<@"+global.notif[t][global.notif[t].length - 1]+">"+types[t].end + +            if(lim == 1 && !found || lim != 1){ +                global.notif[t+"_id"] = await global.channels["general"].send({content:con, flags:[4096]}) +            } else { +                message.edit({content:con, flags:[4096]}) +            } +             + +        }) +    },      async main (client,Discord){          client.on("guildMemberUpdate",(oldMember, newMember)=>{              if(!oldMember.roles.cache.has("761225110060662854") &&  @@ -56,7 +97,7 @@ module.exports = {                  if(global.notif == null)                      global.notif = {}                  if(global.notif.voted == null) -                global.notif.joined = global.notif.voted = [] +                    global.notif.joined = global.notif.voted = []                  global.notif.voted.push(newMember.id) @@ -67,7 +67,7 @@ db.Track = _db_raw.define('Track', {  });  try { -    //db.BattleShip.sync({force:true}) +    db.BattleShip.sync({force:true})      db._raw.authenticate();      console.log('db connected');  } catch (error) { | 
