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 | 8091667711d230a8dc76196a97f17452baf16372 (patch) | |
tree | 02134b904da848691c5ef8bd201786079f2767e6 | |
parent | 51d18877355043c389820b753f717e99d7acf9ce (diff) |
a
-rw-r--r-- | commands/util/status.js | 4 | ||||
-rw-r--r-- | events/member-update.js | 45 | ||||
-rw-r--r-- | src/db.js | 2 |
3 files changed, 46 insertions, 5 deletions
diff --git a/commands/util/status.js b/commands/util/status.js index df71c88..dc05ab7 100644 --- a/commands/util/status.js +++ b/commands/util/status.js @@ -51,7 +51,7 @@ module.exports = { const github = new ButtonBuilder() .setLabel('Github') .setStyle(ButtonStyle.Link) - .setURL('https://github.com/squiresgrant/sns-chan') + .setURL('https://github.com/ameliasquires/sns-chan') const row = new ActionRowBuilder() .addComponents(vote,discord,github); let conv = 1024 * 1024 * 1024 @@ -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) { |