replace all .get( with .resolve(
This commit is contained in:
parent
fddc6394ac
commit
8369f52f90
|
@ -35,7 +35,7 @@ colorRoles.update = async function (member) { // create or remove member's color
|
|||
let member_data = (await dbClient.query(`SELECT (color_role) FROM member_data WHERE id = $1`, [member.id])).rows[0];
|
||||
if (member_data && member_data.color_role) { // it does, reinstantiate it
|
||||
let dbrole = member_data.color_role;
|
||||
let role = member.guild.roles.get(dbrole.id); // get existing role if it still exists somehow
|
||||
let role = member.guild.roles.resolve(dbrole.id); // get existing role if it still exists somehow
|
||||
if (!role) role = await member.guild.roles.create({data:{ // otherwise recreate it
|
||||
name: dbrole.name,
|
||||
color: dbrole.color,
|
||||
|
@ -58,7 +58,7 @@ colorRoles.update = async function (member) { // create or remove member's color
|
|||
|
||||
colorRoles.updateAll = async function() { // update all members' color roles
|
||||
console.log("Updating all color roles");
|
||||
var guild = dClient.defaultGuild || dClient.guilds.get(config.guildID);
|
||||
var guild = dClient.defaultGuild || dClient.guilds.resolve(config.guildID);
|
||||
await guild.members.fetch(); // load all members
|
||||
for (let member of guild.members) {
|
||||
member = member[1];
|
||||
|
@ -74,7 +74,7 @@ colorRoles.updateAll = async function() { // update all members' color roles
|
|||
|
||||
colorRoles.pruneOrphanRoles = async function() { // delete all color roles that have no member
|
||||
console.log("Pruning orphan roles");
|
||||
var guild = dClient.defaultGuild || dClient.guilds.get(config.guildID);
|
||||
var guild = dClient.defaultGuild || dClient.guilds.resolve(config.guildID);
|
||||
for (let role of guild.roles) {
|
||||
role = role[1];
|
||||
if (role.name.startsWith('[') && !role.members.size) {
|
||||
|
|
|
@ -130,8 +130,8 @@ dClient.on('local_message', async message => {
|
|||
message.args = args;
|
||||
message.cmd = cmd;
|
||||
message.txt = function(i){return this.args.slice(i).join(' ')};
|
||||
if (!message.guild) message.guild = dClient.guilds.get(config.guildID);
|
||||
if (!message.member) message.member = dClient.guilds.get(config.guildID).members.get(message.author.id);
|
||||
if (!message.guild) message.guild = dClient.guilds.resolve(config.guildID);
|
||||
if (!message.member) message.member = dClient.guilds.resolve(config.guildID).members.resolve(message.author.id);
|
||||
|
||||
Object.keys(commands).forEach(commandName => {
|
||||
var command = commands[commandName];
|
||||
|
|
|
@ -46,7 +46,7 @@ dbClient.connect().then(function(){
|
|||
|
||||
dClient.once('ready', () => {
|
||||
console.log('Discord Client Ready');
|
||||
dClient.defaultGuild = dClient.guilds.get(config.guildID);
|
||||
dClient.defaultGuild = dClient.guilds.resolve(config.guildID);
|
||||
|
||||
require('./local_events');
|
||||
require('./commands');
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
dClient.on('local_voiceStateUpdate', async (oldState, newState) => {
|
||||
if (oldState.channelID != vcid && newState.channelID == vcid) {
|
||||
// member joined the channel
|
||||
newState.member.roles.add(newState.member.guild.roles.get(rid));
|
||||
newState.member.roles.add(newState.member.guild.roles.resolve(rid));
|
||||
} else if (oldState.channelID == vcid && newState.channelID != vcid) {
|
||||
// member left the channel
|
||||
newState.member.roles.remove(newState.member.guild.roles.get(rid));
|
||||
newState.member.roles.remove(newState.member.guild.roles.resolve(rid));
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
@ -112,7 +112,7 @@ dClient.on("local_emojiDelete", async emoji => {
|
|||
var webhook = new Discord.WebhookClient(config.webhooks.pinboard[0], config.webhooks.pinboard[1]);
|
||||
dClient.on("local_messageReactionAdd", async (messageReaction, user) => {
|
||||
if (!(messageReaction.emoji.name == "📌" || messageReaction.emoji.name == "📍")) return;
|
||||
if (!(user.id == messageReaction.message.author.id || messageReaction.message.guild.members.get(user.id).hasPermission('MANAGE_MESSAGES'))) return;// if message is theirs or user is mod
|
||||
if (!(user.id == messageReaction.message.author.id || messageReaction.message.guild.members.resolve(user.id).hasPermission('MANAGE_MESSAGES'))) return;// if message is theirs or user is mod
|
||||
var message = messageReaction.message;
|
||||
await webhook.send(`https://discordapp.com/channels/${message.guild.id}/${message.channel.id}/${message.id}`, {embeds:[{
|
||||
color: (message.member && message.member.displayColor) || undefined,
|
||||
|
|
|
@ -17,7 +17,7 @@ module.exports = {
|
|||
if (config.disabledRooms.includes(room)) {
|
||||
return msg.reply(`You cannot bridge this room.`);
|
||||
} else /* rebridge */ {
|
||||
let channel = dClient.guilds.get(config.guildID).channels.get(existingBridge.discord_channel_id);
|
||||
let channel = dClient.guilds.resolve(config.guildID).channels.resolve(existingBridge.discord_channel_id);
|
||||
await dbClient.query("UPDATE bridges SET disabled = false WHERE mpp_room = $1 AND site = 'MPP'", [room]);
|
||||
await channel.setParent(config.channels.mpp_bridges);
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
|
@ -33,7 +33,7 @@ module.exports = {
|
|||
/* new bridge */
|
||||
var discordChannelName = room.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase();
|
||||
var categoryID = config.channels.mpp_bridges;
|
||||
var channel = await dClient.guilds.get(config.guildID).channels.create(discordChannelName, {parent: categoryID});
|
||||
var channel = await dClient.guilds.resolve(config.guildID).channels.create(discordChannelName, {parent: categoryID});
|
||||
channel.setTopic(`http://www.multiplayerpiano.com/${encodeURIComponent(room)}`);
|
||||
var webhook = await channel.createWebhook('Webhook');
|
||||
createMPPbridge(room, channel.id, site, webhook.id, webhook.token);
|
||||
|
|
|
@ -10,7 +10,7 @@ module.exports = {
|
|||
if (!(bridge.owner_discord_user_id == msg.author.id || msg.author.id == config.opID)) return msg.react('🚫');
|
||||
|
||||
if (msg.args[1] == 'discord') {
|
||||
let selectedUser = dClient.users.get(msg.args[2]) || msg.mentions.users.first();
|
||||
let selectedUser = dClient.users.resolve(msg.args[2]) || msg.mentions.users.first();
|
||||
if (!selectedUser) return msg.react('⚠️');
|
||||
msg.channel.overwritePermissions(selectedUser, {
|
||||
MANAGE_CHANNELS: true,
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = {
|
|||
await dbClient.query("UPDATE bridges SET disabled = 'true' WHERE mpp_room = $1", [bridge.mpp_room]);
|
||||
var client = clients.MPP[bridge.mpp_room];
|
||||
if (client) client.stop();
|
||||
var channel = dClient.channels.get(bridge.discord_channel_id)
|
||||
var channel = dClient.channels.resolve(bridge.discord_channel_id)
|
||||
await channel.setParent(config.channels.deleted_bridges);
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
await channel.lockPermissions();
|
||||
|
|
|
@ -2,7 +2,7 @@ var Client = require('../lib/Client.js');
|
|||
global.clients = {};
|
||||
|
||||
global.createMPPbridge = function createMPPbridge(room, DiscordChannelID, site = 'MPP', webhookID, webhookToken) {
|
||||
var DiscordChannel = dClient.channels.get(DiscordChannelID);
|
||||
var DiscordChannel = dClient.channels.resolve(DiscordChannelID);
|
||||
if (!DiscordChannel) return console.error(`Couldn't bridge ${site} ${room} because Discord Channel ${DiscordChannelID} is missing!`);
|
||||
if (webhookID && webhookToken) var webhook = new Discord.WebhookClient(webhookID, webhookToken, {disableEveryone:true});
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ var nameCollector = module.exports = {
|
|||
|
||||
var newMsg = function(continued){
|
||||
var str = `__**${participant._id}**__${continued ? ' (continued)' : ''}\n${participant.name}`;
|
||||
return dClient.channels.get(config.channels.name_collection).send(str);
|
||||
return dClient.channels.resolve(config.channels.name_collection).send(str);
|
||||
}
|
||||
|
||||
var document = await this.collection.findOne({_id: participant._id});
|
||||
|
@ -18,7 +18,7 @@ var nameCollector = module.exports = {
|
|||
document.names.push(participant.name);
|
||||
this.collection.updateOne({_id: participant._id}, {$set:{names: document.names}});
|
||||
|
||||
let message = await dClient.channels.get(config.channels.name_collection).messages.fetch(document.discord_msg_id);
|
||||
let message = await dClient.channels.resolve(config.channels.name_collection).messages.fetch(document.discord_msg_id);
|
||||
try {
|
||||
await message.edit(message.content + ', ' + participant.name);
|
||||
} catch(e) {
|
||||
|
|
|
@ -29,7 +29,7 @@ async function messagehandle(data) {
|
|||
let color = data.color;
|
||||
let id = data.sID || data.socketID || data.id;
|
||||
if (id == client.socket.id) return;
|
||||
let c = dClient.channels.get("593943518351982603");
|
||||
let c = dClient.channels.resolve("593943518351982603");
|
||||
let msg;
|
||||
(!name && (data.message.startsWith("[i]"))) ? msg = `*${escapeDiscordMentions(data.message.split("[i]")[1])}*` : msg = `**${sanitizeName(name)}:** ${escapeDiscordMentions(data.message)}`;
|
||||
if (c) c.send(msg);
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
var dcid;
|
||||
for (let x in channelIdMap) if (channelIdMap[x] == m.rid) dcid = x;
|
||||
if (!dcid) return;
|
||||
var dc = dClient.channels.get(dcid);
|
||||
var dc = dClient.channels.resolve(dcid);
|
||||
if (!dc.wh) {
|
||||
dc.wh = (await dc.fetchWebhooks()).find(w=>w.name=="fookat bridge");
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ global.screenshotter = {
|
|||
let screenshot = await page.screenshot({ type: 'png' });
|
||||
let filename = `Screenshot of www.multiplayerpiano.com/lobby @ ${new Date().toISOString()}.png`;
|
||||
let attachment = new Discord.MessageAttachment(screenshot, filename);
|
||||
await dClient.channels.get(config.channels.mpp_screenshot).send(attachment);
|
||||
await dClient.channels.resolve(config.channels.mpp_screenshot).send(attachment);
|
||||
} catch (error) {
|
||||
await dClient.channels.get(config.channels.mpp_screenshot).send(`:warning: ${error.stack}`);
|
||||
await dClient.channels.resolve(config.channels.mpp_screenshot).send(`:warning: ${error.stack}`);
|
||||
}
|
||||
try {
|
||||
await page.goto('http://ourworldofpixels.com');
|
||||
|
@ -36,9 +36,9 @@ global.screenshotter = {
|
|||
let screenshot = await page.screenshot({ type: 'png' });
|
||||
let filename = `Screenshot of ourworldofpixels.com/main @ ${new Date().toISOString()}.png`;
|
||||
let attachment = new Discord.MessageAttachment(screenshot, filename);
|
||||
await dClient.channels.get(config.channels.owop_screenshot).send(attachment);
|
||||
await dClient.channels.resolve(config.channels.owop_screenshot).send(attachment);
|
||||
} catch (error) {
|
||||
await dClient.channels.get(config.channels.owop_screenshot).send(attachment);
|
||||
await dClient.channels.resolve(config.channels.owop_screenshot).send(attachment);
|
||||
}
|
||||
} catch(error) {
|
||||
console.error(`Error occured with screen capture:\n${error.stack}`)
|
||||
|
|
Loading…
Reference in New Issue