Skip to content
1 change: 1 addition & 0 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/**
Expand Down
59 changes: 59 additions & 0 deletions commands/csr_public/channels.js
Original file line number Diff line number Diff line change
@@ -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:
'<prefix>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);
});
25 changes: 25 additions & 0 deletions commands/csr_public/last.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { Message } = require('discord.js');
const { Command } = require('easy-djs-commandhandler');
const last = new Command({
name:'last',
description: "Last Reward posted",
usage:'<prefix>last '});

module.exports = last.execute(async(client, message, args)=>{
let HWMChannel = '600014903775985710';

//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: 5 }) ;
//const daily = msg.map(x => x );
return await message.channel.send(
`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} `);
}
);
19 changes: 18 additions & 1 deletion irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {});
Expand Down
39 changes: 31 additions & 8 deletions ircrules.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
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;
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\`

= HERO WARS REWARDS BOT =
______ ______ ______ ______ ______ஜ۩۞۩ஜ ______ ______ ______ ______ ______
`;
module.exports = code;