Skip to content

Commit

Permalink
update unfollow
Browse files Browse the repository at this point in the history
  • Loading branch information
zenril committed Apr 7, 2023
1 parent 9e5e00e commit a80a616
Show file tree
Hide file tree
Showing 8 changed files with 357 additions and 349 deletions.
2 changes: 1 addition & 1 deletion bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
Common.error('rate limited');
Common.error(info);
});
bot.on('messageCreate', (replayed, shardID) => Common.error(`resume ${shardID}: ` + replayed));
bot.on('shardResume', (replayed, shardID) => Common.error(`resume ${shardID}: ` + replayed));
bot.on('warn', (info) => Common.error('warn:' + info));

bot.on('shardReconnecting', (id) => Common.error(`Shard with ID ${id} reconnected.`));
Expand Down
9 changes: 7 additions & 2 deletions src/commands/modules/bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class Bind extends Command {
} else if (/^(permit)$/i.test(restriction_identifier)) {
server.bindPermit = true;
input.il8nResponse('bind.permit');
} else if (/^(echo)$/i.test(restriction_identifier)) {

input.response(JSON.stringify(server.bind));
} else if (input.args.length > 0) {
const { mentions } = input.message;

Expand All @@ -114,9 +117,11 @@ class Bind extends Command {
const user = server.guild.members.cache.get(id);
const channel = server.guild.channels.cache.get(id);
const role = server.guild.roles.cache.get(id);
if (user || (channel && channel.type != 'voice') || role) continue;

if (!server.bind.includes(id)) server.bind.push(id);
console.log(channel.type);
if (user || channel?.isVoiceBased() !== true || role) continue;

if (!server.bind.includes(id)) server.bind.push(id);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/modules/debugbork.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function debug(msg) {
if (server.isBound()) {
active_server_count++;
var chansize = 'no connection';
if (server.connection) chansize = server.connection.channel.members.size;
if (server.connection) chansize = 0; //server.connection.channel.members.size;
active_server_names +=
server.server_name + '(' + chansize + '): ' + build_permitted_string(server) + '\n';
}
Expand Down
34 changes: 15 additions & 19 deletions src/commands/modules/follow.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ async function follow(msg) {
if (!member.voice.channel.joinable) return msg.il8nResponse('follow.permissions');

if (exceeded_daily_limit(server)) return msg.il8nResponse('follow.limitexceeded');

const errorFunc = (error) => {
msg.il8nResponse('follow.error');
Common.error(error);
server.release();
};

server.setMaster(member);
const connection = await server.joinVoiceChannel(member.voice.channel);

if (!connection) {
await server.joinVoiceChannel(member.voice.channel);
if (!server.connection) {
msg.il8nResponse('follow.error');
server.release();
return;
Expand All @@ -51,7 +51,7 @@ async function follow(msg) {
server.addMemberSetting(member, 'toLanguage', 'default');
commands.notify('follow', { member: member, server: server });
msg.il8nResponse('follow.okay');

// unmute them if they're muted
if (server.getMemberSetting(member, 'muted')) {
server.addMemberSetting(member, 'muted', false);
Expand Down Expand Up @@ -92,10 +92,10 @@ function should_pester(server) {
* * */
function unfollow(msg) {
var server = msg.server;

if (server.connecting) return msg.il8nResponse('unfollow.connecting');
if (server.leaving) return msg.il8nResponse('unfollow.leaving');

if (!server.isBound()) {
msg.il8nResponse('unfollow.none');
return;
Expand All @@ -105,7 +105,7 @@ function unfollow(msg) {
msg.il8nResponse('unfollow.nope');
return;
}

server.release(() => {
commands.notify('unfollow', { member: msg.message.member, server: server });

Expand Down Expand Up @@ -151,9 +151,8 @@ function sidle(msg) {

if (
!newMaster.voice ||
!newMaster.voice.channel ||
!server.guild.voice.connection ||
newMaster.voice.channel.id != server.guild.voice.connection.channel.id
!server.connection ||
newMaster.voice.channel.id != server.connection.joinConfig.channelId
) {
msg.il8nResponse('sidle.novoice');
return;
Expand Down Expand Up @@ -204,11 +203,8 @@ async function transfer(msg) {
return;
}

if (
!newMaster.voice ||
!newMaster.voice.channel ||
(server.guild.voice.channel && newMaster.voice.channel.id != server.connection.channel.id)
) {
let chanId = server?.connection?.joinConfig?.channelId;
if (chanId && newMaster?.voice?.channel?.id != chanId) {
msg.il8nResponse('transfer.samevoice');
return;
}
Expand All @@ -219,14 +215,14 @@ async function transfer(msg) {
}

server.setMaster(newMaster);
if (server.guild.voice.connection) {
if (server.connection) {
msg.il8nResponse('transfer.okay', { name: newMaster.displayName });
} else {
var errorFunc = (err) => {};

$connection = await server.joinVoiceChannel(newMaster.voice.channel);
await server.joinVoiceChannel(newMaster.voice.channel);

if (!$connection) {
if (!server.connection) {
msg.il8nResponse('transfer.error');
server.release();
return;
Expand Down
9 changes: 6 additions & 3 deletions src/helpers/bot-stuff.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*jshint esversion: 9 */

const { Client, Events, GatewayIntentBits, PermissionsBitFieldBitField } = require('discord.js'),
const { Client, Events, GatewayIntentBits, PermissionsBitField } = require('discord.js'),
auth = require('@auth'),
Common = require('@helpers/common'),
tl8 = require('@google-cloud/translate').v2;
Expand Down Expand Up @@ -54,8 +54,11 @@ class BotStuff {
let botMember = server.guild.members.cache.find((x) => x.id == this.bot.user.id);
if (!botMember) return Common.error(new Error('Cant find the member object for this bot')); // something went wrong!

let rtn = botMember.hasPermission(PermissionsBitField.Flags.ManageMessages, false, true, true);
return rtn;
// member

// let rtn = botMember.hasPermission(PermissionsBitField.Flags.ManageMessages, false, true, true);

return botMember.permissions.has(PermissionsBitField.Flags.ManageMessages, true);
}

sendMessage(channel_id, message) {
Expand Down
Loading

0 comments on commit a80a616

Please sign in to comment.