From efa691119ef18dc72b7af7ca020b4e1af40bdcc3 Mon Sep 17 00:00:00 2001 From: thething Date: Sun, 3 May 2020 02:31:22 -0400 Subject: [PATCH 01/12] Update ircrules.js --- ircrules.js | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/ircrules.js b/ircrules.js index ae27757..959a020 100644 --- a/ircrules.js +++ b/ircrules.js @@ -1,10 +1,32 @@ -const code = `**\`\`1. be friendly:\`\`** -this isnt a server,its multiple servers communicating, and there can be people who might take offense to what you type. -**\`\`2. no advertising in #irc.\`\`** -**\`\`3. no enforcing political viewpoints on people.\`\`** -**\`\`4. no spamming in the irc channel.\`\`**\n**\`\`5. no nsfw in the irc channel\`\`** -**\`\`6. Harassing CSR Staff is punishable with a Ban\`\`** -**\`\`7. Any attempt to create and exploit loopholes will result in an unappealable Ban\`\`** +/*const code = ` +**\`\`___________________ஜ۩۞۩ஜ__________________\`\`** +**\`\`= HERO WARS REWARDS BOT =\`\`** +**\`\`___________________ஜ۩۞۩ஜ__________________\`\`** +**\`\` \xa0 +Rewards bot is a feed from Hero Wars Mobile \xa0\nDiscord server. \xa0 +Heroes all across the dominion will receive \xa0\nthe info posted to us. \xa0 +New users and other public information will \xa0\nbe posted in our public channel. \xa0 +Failure to respect staff and others will be \xa0\nhandled accordingly. \xa0 +To connect simply type the following command\xa0\nin your designated bot channel: 'c-connect \xa0 +#your-channel-name private HeroWarsRewards' \xa0 +Other commands 'c-stats' and 'c-testwebhooks' + \xa0 += HERO WARS REWARDS BOT = +___________________ஜ۩۞۩ஜ___________________\`\`** `; +*/ +const code = ` +_________________....----++++ஜ۩۞۩ஜ++++----...._________________ +** \xa0= HERO WARS REWARDS BOT = ** -module.exports = code; \ No newline at end of file +Rewards bot is a feed from Hero Wars Mobile \xa0\nDiscord server. \xa0 +Heroes all across the dominion will receive \xa0\nthe info posted to us. \xa0 +New users and other public information will \xa0\nbe posted in our public channel. \xa0 +Failure to respect staff and others will be \xa0\nhandled accordingly. \xa0 +To connect simply type the following command\xa0\nin your designated bot channel: \`c-connect \xa0 +#your-channel-name private HeroWarsRewards\` \xa0 +Other commands \`c-stats\` and \`c-testwebhooks\` + \xa0 += HERO WARS REWARDS BOT = +______ ______ ______ ______ ______ஜ۩۞۩ஜ ______ ______ ______ ______ ______ +`; From 1ee08adcbdacad005e11dc3aa75b6305311a2c1e Mon Sep 17 00:00:00 2001 From: thething Date: Sun, 3 May 2020 02:36:50 -0400 Subject: [PATCH 02/12] Update ircrules.js --- ircrules.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ircrules.js b/ircrules.js index 959a020..63ae347 100644 --- a/ircrules.js +++ b/ircrules.js @@ -19,14 +19,14 @@ const code = ` _________________....----++++ஜ۩۞۩ஜ++++----...._________________ ** \xa0= HERO WARS REWARDS BOT = ** -Rewards bot is a feed from Hero Wars Mobile \xa0\nDiscord server. \xa0 -Heroes all across the dominion will receive \xa0\nthe info posted to us. \xa0 -New users and other public information will \xa0\nbe posted in our public channel. \xa0 -Failure to respect staff and others will be \xa0\nhandled accordingly. \xa0 -To connect simply type the following command\xa0\nin your designated bot channel: \`c-connect \xa0 -#your-channel-name private HeroWarsRewards\` \xa0 +Rewards bot is a feed from Hero Wars Mobile \nDiscord server. +Heroes all across the dominion will receive \nthe info posted to us. +New users and other public information will \nbe posted in our public channel. +Failure to respect staff and others will be \nhandled accordingly. +To connect simply type the following command\nin your designated bot channel: \`c-connect +#your-channel-name private HeroWarsRewards\` Other commands \`c-stats\` and \`c-testwebhooks\` - \xa0 + = HERO WARS REWARDS BOT = ______ ______ ______ ______ ______ஜ۩۞۩ஜ ______ ______ ______ ______ ______ `; From 45ad6f8335d0878a45452451b548cf7563e52c5f Mon Sep 17 00:00:00 2001 From: thething Date: Tue, 12 May 2020 17:44:24 -0400 Subject: [PATCH 03/12] Get last 3 messages of HWM Channel --- commands/csr_public/last.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 commands/csr_public/last.js diff --git a/commands/csr_public/last.js b/commands/csr_public/last.js new file mode 100644 index 0000000..bb75dc9 --- /dev/null +++ b/commands/csr_public/last.js @@ -0,0 +1,24 @@ +const { Message } = require('discord.js'); +const { Command } = require('easy-djs-commandhandler'); +const last = new Command({ + name:'last', + description: "Last Reward posted", + usage:'last ', + hideinhelp:true }); + +module.exports = last.execute((client, message, args)=>{ + + let target = message.guild.channels.find(c => c.id == client.HWMChannel) || null; // find the targeted channel + if (target) { // make sure that the targeted channel exists, if it exists then fetch its last message + target + .fetchMessages({ limit: 3 }) + .then(f => + message.channel.send( + `Last 3 Rewards: \n> ${f.array()[2].content} \n> ${f.array()[1].content} \n> ${f.first().content} ` + ) // send the last message to the initial channel + ); + } else { //if target doesn't exist, send an error + message.channel.send("Hero Mobile Channel ID is not set."); + } + +}); From 1df87a1dfee4c48d42aea539e1d6b7f69f4aa44f Mon Sep 17 00:00:00 2001 From: thething Date: Tue, 12 May 2020 17:46:00 -0400 Subject: [PATCH 04/12] Added HWMChannel for referencing. --- bot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/bot.js b/bot.js index 412e994..c793ff6 100644 --- a/bot.js +++ b/bot.js @@ -19,6 +19,7 @@ class Bot extends discord.Client { super(options); this.allowedServers=['688259277688930325', '462007482001391616'] this.errorChannel="688466079575834769" + this.HWMChannel="600014903775985710" //For Last.js this.db = new jndb.Connection(); this.system = new System(this); /** From f3b36be3b34be8dc83aadd8a1d66a223bb66a0cd Mon Sep 17 00:00:00 2001 From: thething Date: Tue, 12 May 2020 18:13:40 -0400 Subject: [PATCH 05/12] Update last.js --- commands/csr_public/last.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/commands/csr_public/last.js b/commands/csr_public/last.js index bb75dc9..82596bd 100644 --- a/commands/csr_public/last.js +++ b/commands/csr_public/last.js @@ -3,8 +3,7 @@ const { Command } = require('easy-djs-commandhandler'); const last = new Command({ name:'last', description: "Last Reward posted", - usage:'last ', - hideinhelp:true }); + usage:'last '}); module.exports = last.execute((client, message, args)=>{ From 8762e1d57eeda673ac998c292c42c132ce71d0f4 Mon Sep 17 00:00:00 2001 From: thething Date: Tue, 12 May 2020 22:10:15 -0400 Subject: [PATCH 06/12] Update ircrules.js --- ircrules.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ircrules.js b/ircrules.js index 63ae347..d41732c 100644 --- a/ircrules.js +++ b/ircrules.js @@ -30,3 +30,4 @@ Other commands \`c-stats\` and \`c-testwebhooks\` = HERO WARS REWARDS BOT = ______ ______ ______ ______ ______ஜ۩۞۩ஜ ______ ______ ______ ______ ______ `; +module.exports = code; From 37d4c55af4245440fdf23e7dde901ea4f1ad5a37 Mon Sep 17 00:00:00 2001 From: thething Date: Tue, 12 May 2020 22:13:41 -0400 Subject: [PATCH 07/12] Update last.js --- commands/csr_public/last.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/commands/csr_public/last.js b/commands/csr_public/last.js index 82596bd..290c1cd 100644 --- a/commands/csr_public/last.js +++ b/commands/csr_public/last.js @@ -5,19 +5,19 @@ const last = new Command({ description: "Last Reward posted", usage:'last '}); -module.exports = last.execute((client, message, args)=>{ - - let target = message.guild.channels.find(c => c.id == client.HWMChannel) || null; // find the targeted channel - if (target) { // make sure that the targeted channel exists, if it exists then fetch its last message - target - .fetchMessages({ limit: 3 }) - .then(f => - message.channel.send( - `Last 3 Rewards: \n> ${f.array()[2].content} \n> ${f.array()[1].content} \n> ${f.first().content} ` - ) // send the last message to the initial channel - ); - } else { //if target doesn't exist, send an error - message.channel.send("Hero Mobile Channel ID is not set."); - } - +module.exports = last.execute((client, message, args)=>{ + + let target = client.channels.get(client.HWMChannel); // find the targeted channel + + if (!target) { + message.channel.send("Hero Mobile Channel ID is not set."); + return + } + + // send the last message to the initial channel + setTimeout(async function() { + const msg = await target.fetchMessages({ limit: 3 }).then(msg => message.channel.send( + `Last 3 Rewards: \n> ${msg.array()[2].content} \n> ${msg.array()[1].content} \n> ${msg.first().content} `)); + + }); }); From f6d7fc93d9b35ec14abf29d9b4f91f3f0ffee776 Mon Sep 17 00:00:00 2001 From: thething Date: Tue, 12 May 2020 23:48:23 -0400 Subject: [PATCH 08/12] Update last.js --- commands/csr_public/last.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/commands/csr_public/last.js b/commands/csr_public/last.js index 290c1cd..df65e08 100644 --- a/commands/csr_public/last.js +++ b/commands/csr_public/last.js @@ -5,19 +5,18 @@ const last = new Command({ description: "Last Reward posted", usage:'last '}); -module.exports = last.execute((client, message, args)=>{ - - let target = client.channels.get(client.HWMChannel); // find the targeted channel - +module.exports = last.execute(async(client, message, args)=>{ + + let target = client.channels.get(client.HWMChannel); // find the targeted channel if (!target) { message.channel.send("Hero Mobile Channel ID is not set."); return - } + } - // send the last message to the initial channel - setTimeout(async function() { - const msg = await target.fetchMessages({ limit: 3 }).then(msg => message.channel.send( - `Last 3 Rewards: \n> ${msg.array()[2].content} \n> ${msg.array()[1].content} \n> ${msg.first().content} `)); - - }); -}); + const msg = await + target.fetchMessages({ limit: 3 }) + .then(msg => message.channel.send( + `Last 3 Rewards: \n> ${msg.array()[2].content} \n> ${msg.array()[1].content} \n> ${msg.first().content} `)); + // send the last message to the initial channel + } +); From cf73b9f0bd49841c3fee8c96583b98700cdf317d Mon Sep 17 00:00:00 2001 From: thething Date: Fri, 15 May 2020 23:36:12 -0400 Subject: [PATCH 09/12] Update last.js --- commands/csr_public/last.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/commands/csr_public/last.js b/commands/csr_public/last.js index df65e08..d864cce 100644 --- a/commands/csr_public/last.js +++ b/commands/csr_public/last.js @@ -5,18 +5,16 @@ const last = new Command({ description: "Last Reward posted", usage:'last '}); -module.exports = last.execute(async(client, message, args)=>{ +module.exports = last.execute(async(client, message, args)=>{ let target = client.channels.get(client.HWMChannel); // find the targeted channel if (!target) { message.channel.send("Hero Mobile Channel ID is not set."); return } - - const msg = await - target.fetchMessages({ limit: 3 }) - .then(msg => message.channel.send( - `Last 3 Rewards: \n> ${msg.array()[2].content} \n> ${msg.array()[1].content} \n> ${msg.first().content} `)); - // send the last message to the initial channel + + const msg = await target.fetchMessages({ limit: 3 }); + return await message.channel.send( + `Last 3 Rewards: ${msg.map( x=> '\n> ' + x )} `); } -); +); From 851b80e8c591fa419e87e0bb87e1201e1e753948 Mon Sep 17 00:00:00 2001 From: thething Date: Tue, 21 Jul 2020 17:54:02 -0400 Subject: [PATCH 10/12] Added private channel to connect when joining Added private channel to connect when joining Changed irc (public channel) name Added private joining Creates 2 channels --- irc.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/irc.js b/irc.js index 9e32edf..4e4ed0e 100644 --- a/irc.js +++ b/irc.js @@ -124,7 +124,24 @@ client.on('guildCreate', async (guild) => { * @type {Discord.TextChannel} */ // @ts-ignore - let irc = await guild.createChannel('irc', { type: 'text' }).catch(() => {}); + let hwb = await guild.createChannel('Hero Wars Reward', { type: 'text' }).catch(() => {}); + if (hwb) { + await hwb.send(client).catch(() => {}); + let webhook = await hwb.createWebhook('csr').catch(() => {}); + if (webhook) client.system.webhookManager.add(guild, { private: webhook }); + hwb.passcode="HeroWarsRewards" + //new PrivateChannel(client.system,textchannel,passcode) + client.system.channels.create(guild, { privateChannel: hwb }); + } + }); + + +//Connect Public Channel +client.on('guildCreate', async (guild) => { + if (!guild.available) { + return; + } + let irc = await guild.createChannel('Rewards Public Info', { type: 'text' }).catch(() => {}); if (irc) { await irc.send(client.rules).catch(() => {}); let webhook = await irc.createWebhook('csr').catch(() => {}); From 7c4ce516ad410a91cd972808c2ff5393bb523588 Mon Sep 17 00:00:00 2001 From: thething Date: Tue, 21 Jul 2020 17:56:05 -0400 Subject: [PATCH 11/12] Update last.js --- commands/csr_public/last.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/commands/csr_public/last.js b/commands/csr_public/last.js index d864cce..4bbaed3 100644 --- a/commands/csr_public/last.js +++ b/commands/csr_public/last.js @@ -5,16 +5,21 @@ const last = new Command({ description: "Last Reward posted", usage:'last '}); -module.exports = last.execute(async(client, message, args)=>{ +module.exports = last.execute(async(client, message, args)=>{ +let HWMChannel = '600014903775985710'; - let target = client.channels.get(client.HWMChannel); // find the targeted channel + //let target = client.channels.get(client.HWMChannel); + let target = client.channels.get(HWMChannel); // find the targeted channel if (!target) { message.channel.send("Hero Mobile Channel ID is not set."); return - } + } - const msg = await target.fetchMessages({ limit: 3 }); + const msg = await target.fetchMessages({ limit: 5 }) ; + //const daily = msg.map(x => x ); return await message.channel.send( - `Last 3 Rewards: ${msg.map( x=> '\n> ' + x )} `); + `Last 5 Rewards: \`\`\`${msg.map( x=> '\n ' + x )} \`\`\` `); + //`Last 3 Rewards: ${msg.map( x=> '\n> ' + x )} `); + //`Last 3 Rewards: \n> ${msg.map} \n> ${msg.map(x => x )} \n> ${msg.first().content} `); } -); +); From eff665cc029093ab016b3a4c793082fb801a992f Mon Sep 17 00:00:00 2001 From: thething Date: Thu, 23 Jul 2020 22:36:19 -0400 Subject: [PATCH 12/12] Connect and create private And public channels --- commands/csr_public/channels.js | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 commands/csr_public/channels.js diff --git a/commands/csr_public/channels.js b/commands/csr_public/channels.js new file mode 100644 index 0000000..f19949c --- /dev/null +++ b/commands/csr_public/channels.js @@ -0,0 +1,59 @@ +const { Command } = require('easy-djs-commandhandler'); +const Default = new Command({ + name: 'default', + requires: ['guild'], + requiresBotPermissions: ['EMBED_LINKS'], + description: "Creates and connects to Hero Wars Reward and Rewards Public Info channels", + usage: + 'default ', + requireUserPermissions: ['MANAGE_CHANNELS'], +}); +let allowedTypes = ['public', 'private']; +/** @param {import("../../bot")} callback */ +module.exports = Default.execute(async (client, message, args) => { + let type = args[0]; + if (!allowedTypes.includes(type)) { + return message.channel.send('invalid type, try '+client.prefix+'default [private | public}'); + } + // Private + //client.on('guildCreate', async (guild) => { + let guild = message.guild.id; + let chs = client.system.getChannels(message.guild); + if (type == 'private') { + if (!message.guild.available) { return; } + if (chs.private){ + return message.channel.send('Channel already exist. Please try `'+client.prefix+'disconnect private` before trying again'); + return; + } + let hwb = await message.guild.createChannel('Hero Wars Reward', { type: 'text' }).catch(() => {}); + let HWMmessage = "Connected"; + await hwb.send(HWMmessage).catch(() => {}); + let webhook = await hwb.createWebhook('HeroWars').catch(() => {}); + if (webhook) client.system.webhookManager.add(guild, { private: webhook }); + hwb.passcode="HeroWarsRewards" + client.system.channels.create(message.guild, { privateChannel: hwb }); + console.log('joined private server ' + message.guild.name + ' Using default command'); + return message.channel.send('if `'+client.prefix+'testwebhooks` is ok, then your guild is connected and ready to receive our rewards. '); +} + if (type == 'public') { + if (!message.guild.available) {return;} + if (chs.public){ + return message.channel.send('Channel already exist. Please try `'+client.prefix+'disconnect public` before trying again'); + return; + } + let irc = await message.guild.createChannel('Rewards Public Info', { type: 'text' }).catch(() => {}); + if (irc) { + await irc.send(client.rules).catch(() => {}); + let webhook = await irc.createWebhook('csr').catch(() => {}); + if (webhook) client.system.webhookManager.add(guild, { private: webhook }); + client.system.channels.create(message.guild, { publicChannel: irc }); + console.log('joined public server ' + message.guild.name + ' Using default command'); + return message.channel.send('You will now receve all channel info from the bot. Type `'+client.prefix+'disconnect public` if you dont want to get this info. '); + } +} + const ed = new Discord.RichEmbed() + .setColor(client.color) + .setAuthor(`${guild.name}`, guild.iconURL || client.user.defaultAvatarURL) + .setDescription(`has joined ${client.system.findEmoji('join')}`); + client.system.sendAll(ed); +});