aboutsummaryrefslogtreecommitdiff
path: root/events
diff options
context:
space:
mode:
Diffstat (limited to 'events')
-rw-r--r--events/defaults/member-add.js.json1
-rw-r--r--events/defaults/member-update.js.json1
-rw-r--r--events/defaults/ready.js.json6
-rw-r--r--events/interaction.js1
-rw-r--r--events/member-add.js26
-rw-r--r--events/member-update.js69
6 files changed, 101 insertions, 3 deletions
diff --git a/events/defaults/member-add.js.json b/events/defaults/member-add.js.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/events/defaults/member-add.js.json
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/events/defaults/member-update.js.json b/events/defaults/member-update.js.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/events/defaults/member-update.js.json
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/events/defaults/ready.js.json b/events/defaults/ready.js.json
index 4ee756c..fc6ae30 100644
--- a/events/defaults/ready.js.json
+++ b/events/defaults/ready.js.json
@@ -1,5 +1,5 @@
{
- "status":{"value":"dm to report an issue"},
- "type":{"value":"Playing","options":["Listening","Playing","Streaming","Watching"]},
+ "status":{"value":"discord.gg/supernoobs"},
+ "type":{"value":"Custom","options":["Listening","Playing","Streaming","Watching", "Custom"]},
"timed_interval":{"value":5000}
-} \ No newline at end of file
+}
diff --git a/events/interaction.js b/events/interaction.js
index a9a174f..e384dcc 100644
--- a/events/interaction.js
+++ b/events/interaction.js
@@ -13,6 +13,7 @@ module.exports = {
await db._raw.sync()
let config = JSON.parse(fs.readFileSync(config_loc))
client.on("interactionCreate", async(interaction) => {
+
if(interaction.guild==null)return
if(!settings["allowed-servers"].includes(interaction.guild.id))
return console.log("denied interaction from (guild)"+interaction.guild.id)
diff --git a/events/member-add.js b/events/member-add.js
new file mode 100644
index 0000000..6392c4c
--- /dev/null
+++ b/events/member-add.js
@@ -0,0 +1,26 @@
+const { ActivityType , PermissionsBitField} = require("discord.js");
+const fs = require('fs')
+const path = require("path");
+const { EmbedBuilder } = require("discord.js");
+let db = require("../src/db")
+let settings = require("../src/settings")
+let message_update = require("./member-update")
+let config_loc = __filename+".json"
+module.exports = {
+ name : "guildMemberAdd",
+ config_loc : config_loc,
+ async main (client,Discord){
+ client.on("guildMemberAdd",(m)=>{
+ //global.channels.general.send("Welcome to the server <@"+m.id+">!")
+ if(global.notif == null)
+ global.notif = {}
+ if(global.notif.voted == null)
+ global.notif.joined = global.notif.voted = []
+
+ global.notif.joined.push(m.id)
+
+ message_update.build_message(m.id, "joined")
+ })
+
+ },
+} \ No newline at end of file
diff --git a/events/member-update.js b/events/member-update.js
new file mode 100644
index 0000000..bbdc889
--- /dev/null
+++ b/events/member-update.js
@@ -0,0 +1,69 @@
+const { ActivityType , PermissionsBitField, ActionRowBuilder,ButtonBuilder,ButtonStyle } = require("discord.js");
+const fs = require('fs')
+const path = require("path");
+const { EmbedBuilder } = require("discord.js");
+let db = require("../src/db")
+let settings = require("../src/settings")
+let config_loc = __filename+".json"
+module.exports = {
+ name : "guildMemberUpdate",
+ config_loc : config_loc,
+ build_message(p, t){
+ global.channels["general"].messages.fetch({limit : 1}).then(async messages => {
+ let message = messages.first();
+ if(message.id == global.notif.id){
+ //edit
+ let mess = "";
+ //TODO: this can be a single loop
+ if(global.notif.voted.length != 0){
+ for(let i = 0; i != global.notif.voted.length - 1; i++){
+ mess += "<@"+global.notif.voted[i]+">, ";
+ }
+ if(global.notif.voted.length > 1) mess += " and"
+ mess += " <@"+global.notif.voted[global.notif.voted.length - 1]+"> just voted! You can too by clicking [here](https://discords.com/servers/486957006628847626/upvote)"
+ }
+
+ if(global.notif.joined.length != 0){
+ if(global.notif.voted.length != 0) mess += " and\n"
+ mess += "Welcome to the server "
+ for(let i = 0; i != global.notif.joined.length - 1; i++){
+ mess += "<@"+global.notif.joined[i]+">, ";
+ }
+ if(global.notif.joined.length > 1) mess += " and"
+ mess += " <@"+global.notif.joined[global.notif.joined.length - 1]+">!"
+ }
+ message.edit({content: mess, flags:[4096]})
+ } else {
+ global.notif.voted = []
+ global.notif.joined = []
+ global.notif[t] = [p]
+
+ if(t == "voted"){
+ global.notif.id = await global.channels["general"].send({content:`<@${p}> just voted! You can too by clicking [here](https://discords.com/servers/486957006628847626/upvote).`,
+ flags: [ 4096 ]})
+ } else if(t == "joined"){
+ global.notif.id = await global.channels["general"].send({content:`Welcome to the server <@${p}>!`,
+ flags: [ 4096 ]})
+ }
+ }
+ })
+ },
+ async main (client,Discord){
+ client.on("guildMemberUpdate",(oldMember, newMember)=>{
+ if(!oldMember.roles.cache.has("761225110060662854") &&
+ newMember.roles.cache.has("761225110060662854")){
+
+ if(global.notif == null)
+ global.notif = {}
+ if(global.notif.voted == null)
+ global.notif.joined = global.notif.voted = []
+
+ global.notif.voted.push(newMember.id)
+
+ this.build_message(newMember.id, "voted")
+
+
+ }
+ })
+ },
+} \ No newline at end of file