Skip to content

Commit

Permalink
Merge pull request #526 from aternosorg/intervals
Browse files Browse the repository at this point in the history
fix unbanning in guilds the bot has been kicked from
  • Loading branch information
JulianVennen authored Nov 2, 2022
2 parents 550fafa + b2da972 commit dfe2c12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/discord/GuildWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class GuildWrapper {
return new this(await bot.client.guilds.fetch(id));
}
catch (e) {
if (e.code === RESTJSONErrorCodes.UnknownGuild) {
if ([RESTJSONErrorCodes.UnknownGuild, RESTJSONErrorCodes.MissingAccess].includes(e.code)) {
return null;
}
throw e;
Expand Down
6 changes: 6 additions & 0 deletions src/interval/UnbanInterval.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export default class UnbanInterval extends Interval {
/** @property {number} insertId */
const unban = await database.queryAll('INSERT INTO moderations (guildid, userid, action, created, reason, active) VALUES (?,?,?,?,?,?)', result.guildid, result.userid, 'unban', Math.floor(Date.now()/1000), reason, false);
const guild = await GuildWrapper.fetch(result.guildid);

if (!guild) {
const wrapper = new GuildWrapper({id: result.guildid});
await wrapper.deleteData();
}

const member = new MemberWrapper(user, guild);

await database.query('UPDATE moderations SET active = FALSE WHERE action = \'ban\' AND userid = ? AND guildid = ?',result.userid, result.guildid);
Expand Down

0 comments on commit dfe2c12

Please sign in to comment.