Update DJS
This commit is contained in:
parent
ac619ec00f
commit
5e73d380c5
23 changed files with 71 additions and 56 deletions
34
backend/package-lock.json
generated
34
backend/package-lock.json
generated
|
@ -14,7 +14,7 @@
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cross-env": "^5.2.0",
|
"cross-env": "^5.2.0",
|
||||||
"deep-diff": "^1.0.2",
|
"deep-diff": "^1.0.2",
|
||||||
"discord.js": "^13.0.0-dev.a08ce7d.1625097834",
|
"discord.js": "^13.0.0-dev.ab0b3b9.1625400166",
|
||||||
"dotenv": "^4.0.0",
|
"dotenv": "^4.0.0",
|
||||||
"emoji-regex": "^8.0.0",
|
"emoji-regex": "^8.0.0",
|
||||||
"erlpack": "github:discord/erlpack",
|
"erlpack": "github:discord/erlpack",
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/voice": "^0.5.1",
|
"@discordjs/voice": "^0.5.1",
|
||||||
"discord-api-types": "^0.18.1",
|
"discord-api-types": "^0.18.1",
|
||||||
"discord.js": "^13.0.0-dev.a08ce7d.1625097834",
|
"discord.js": "^13.0.0-dev.ab0b3b9.1625400166",
|
||||||
"knub-command-manager": "^9.1.0",
|
"knub-command-manager": "^9.1.0",
|
||||||
"ts-essentials": "^6.0.7"
|
"ts-essentials": "^6.0.7"
|
||||||
},
|
},
|
||||||
|
@ -162,9 +162,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@discordjs/builders": {
|
"node_modules/@discordjs/builders": {
|
||||||
"version": "0.1.1",
|
"version": "0.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.2.0.tgz",
|
||||||
"integrity": "sha512-9eBC22bX2HBsob5ixMwZ6quy/vewU5GHuSJhpmSZ3cDGg8XPnrYdzbwI54U+V9kQBTa7M+aMu1lYVqMEPojj8A==",
|
"integrity": "sha512-TVq7NZBCJrrTRc3CfxOr3IdgY5nrtqVxZ7qDUF1mN6LgxIiOldmFxsSwMrQBzLFVmOwqFyNLKCeblley8UpEuw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord-api-types": "^0.18.1",
|
"discord-api-types": "^0.18.1",
|
||||||
"tslib": "^2.3.0"
|
"tslib": "^2.3.0"
|
||||||
|
@ -2160,11 +2160,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/discord.js": {
|
"node_modules/discord.js": {
|
||||||
"version": "13.0.0-dev.a08ce7d.1625097834",
|
"version": "13.0.0-dev.ab0b3b9.1625400166",
|
||||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.0.0-dev.a08ce7d.1625097834.tgz",
|
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.0.0-dev.ab0b3b9.1625400166.tgz",
|
||||||
"integrity": "sha512-JqtGLMxXWKebpV8t4WV/kfCnTdkH4XCQceWcaYH3kZatXHiUNDzypv/Qgi5e8ioSeVKWMQzAaxg5Epm8bpOfZw==",
|
"integrity": "sha512-nTdUyPEvy1OxCoSXVJrJDFMxEIEUr/NIpuf8x0gz0XTdrghDrGR756hX4KuqGT12fm9PpqciyT+52f7fkzIxCQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/builders": "^0.1.1",
|
"@discordjs/builders": "^0.2.0",
|
||||||
"@discordjs/collection": "^0.1.6",
|
"@discordjs/collection": "^0.1.6",
|
||||||
"@discordjs/form-data": "^3.0.1",
|
"@discordjs/form-data": "^3.0.1",
|
||||||
"@sapphire/async-queue": "^1.1.4",
|
"@sapphire/async-queue": "^1.1.4",
|
||||||
|
@ -6438,9 +6438,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@discordjs/builders": {
|
"@discordjs/builders": {
|
||||||
"version": "0.1.1",
|
"version": "0.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.2.0.tgz",
|
||||||
"integrity": "sha512-9eBC22bX2HBsob5ixMwZ6quy/vewU5GHuSJhpmSZ3cDGg8XPnrYdzbwI54U+V9kQBTa7M+aMu1lYVqMEPojj8A==",
|
"integrity": "sha512-TVq7NZBCJrrTRc3CfxOr3IdgY5nrtqVxZ7qDUF1mN6LgxIiOldmFxsSwMrQBzLFVmOwqFyNLKCeblley8UpEuw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"discord-api-types": "^0.18.1",
|
"discord-api-types": "^0.18.1",
|
||||||
"tslib": "^2.3.0"
|
"tslib": "^2.3.0"
|
||||||
|
@ -8035,11 +8035,11 @@
|
||||||
"integrity": "sha512-hNC38R9ZF4uaujaZQtQfm5CdQO58uhdkoHQAVvMfIL0LgOSZeW575W8H6upngQOuoxWd8tiRII3LLJm9zuQKYg=="
|
"integrity": "sha512-hNC38R9ZF4uaujaZQtQfm5CdQO58uhdkoHQAVvMfIL0LgOSZeW575W8H6upngQOuoxWd8tiRII3LLJm9zuQKYg=="
|
||||||
},
|
},
|
||||||
"discord.js": {
|
"discord.js": {
|
||||||
"version": "13.0.0-dev.a08ce7d.1625097834",
|
"version": "13.0.0-dev.ab0b3b9.1625400166",
|
||||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.0.0-dev.a08ce7d.1625097834.tgz",
|
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.0.0-dev.ab0b3b9.1625400166.tgz",
|
||||||
"integrity": "sha512-JqtGLMxXWKebpV8t4WV/kfCnTdkH4XCQceWcaYH3kZatXHiUNDzypv/Qgi5e8ioSeVKWMQzAaxg5Epm8bpOfZw==",
|
"integrity": "sha512-nTdUyPEvy1OxCoSXVJrJDFMxEIEUr/NIpuf8x0gz0XTdrghDrGR756hX4KuqGT12fm9PpqciyT+52f7fkzIxCQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@discordjs/builders": "^0.1.1",
|
"@discordjs/builders": "^0.2.0",
|
||||||
"@discordjs/collection": "^0.1.6",
|
"@discordjs/collection": "^0.1.6",
|
||||||
"@discordjs/form-data": "^3.0.1",
|
"@discordjs/form-data": "^3.0.1",
|
||||||
"@sapphire/async-queue": "^1.1.4",
|
"@sapphire/async-queue": "^1.1.4",
|
||||||
|
@ -8880,7 +8880,7 @@
|
||||||
"@typescript-eslint/parser": "^4.23.0",
|
"@typescript-eslint/parser": "^4.23.0",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"discord-api-types": "^0.18.1",
|
"discord-api-types": "^0.18.1",
|
||||||
"discord.js": "^13.0.0-dev.a08ce7d.1625097834",
|
"discord.js": "^13.0.0-dev.ab0b3b9.1625400166",
|
||||||
"eslint": "^7.2.0",
|
"eslint": "^7.2.0",
|
||||||
"husky": "^4.3.8",
|
"husky": "^4.3.8",
|
||||||
"knub-command-manager": "^9.1.0",
|
"knub-command-manager": "^9.1.0",
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cross-env": "^5.2.0",
|
"cross-env": "^5.2.0",
|
||||||
"deep-diff": "^1.0.2",
|
"deep-diff": "^1.0.2",
|
||||||
"discord.js": "^13.0.0-dev.a08ce7d.1625097834",
|
"discord.js": "^13.0.0-dev.ab0b3b9.1625400166",
|
||||||
"dotenv": "^4.0.0",
|
"dotenv": "^4.0.0",
|
||||||
"emoji-regex": "^8.0.0",
|
"emoji-regex": "^8.0.0",
|
||||||
"erlpack": "github:discord/erlpack",
|
"erlpack": "github:discord/erlpack",
|
||||||
|
|
|
@ -263,8 +263,8 @@ connect().then(async () => {
|
||||||
startUptimeCounter();
|
startUptimeCounter();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bot.initialize();
|
||||||
|
logger.info("Bot Initialized");
|
||||||
logger.info("Logging in...");
|
logger.info("Logging in...");
|
||||||
await client.login(process.env.token);
|
await client.login(process.env.token);
|
||||||
logger.info("Initializing the bot");
|
|
||||||
bot.initialize();
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { autoReactionsEvt } from "../types";
|
||||||
const p = Permissions.FLAGS;
|
const p = Permissions.FLAGS;
|
||||||
|
|
||||||
export const AddReactionsEvt = autoReactionsEvt({
|
export const AddReactionsEvt = autoReactionsEvt({
|
||||||
event: "message",
|
event: "messageCreate",
|
||||||
allowBots: true,
|
allowBots: true,
|
||||||
allowSelf: true,
|
allowSelf: true,
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { MessageOptions } from "discord.js";
|
import { MessageEditOptions, MessageOptions } from "discord.js";
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes";
|
import { CaseTypes } from "../../../data/CaseTypes";
|
||||||
|
@ -14,7 +14,7 @@ export async function getCaseEmbed(
|
||||||
caseOrCaseId: Case | number,
|
caseOrCaseId: Case | number,
|
||||||
requestMemberId?: string,
|
requestMemberId?: string,
|
||||||
noOriginalCaseLink?: boolean,
|
noOriginalCaseLink?: boolean,
|
||||||
): Promise<MessageOptions> {
|
): Promise<MessageOptions & MessageEditOptions> {
|
||||||
const theCase = await pluginData.state.cases.with("notes").find(resolveCaseId(caseOrCaseId));
|
const theCase = await pluginData.state.cases.with("notes").find(resolveCaseId(caseOrCaseId));
|
||||||
if (!theCase) {
|
if (!theCase) {
|
||||||
throw new Error("Unknown case");
|
throw new Error("Unknown case");
|
||||||
|
|
|
@ -54,14 +54,14 @@ export async function handleCompanionPermissions(
|
||||||
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
|
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
|
||||||
if (!channel || !(channel instanceof TextChannel)) continue;
|
if (!channel || !(channel instanceof TextChannel)) continue;
|
||||||
await channel.permissionOverwrites
|
await channel.permissionOverwrites
|
||||||
.get(userId as Snowflake)
|
.resolve(userId as Snowflake)
|
||||||
?.delete(`Companion Channel for ${oldChannel!.id} | User Left`);
|
?.delete(`Companion Channel for ${oldChannel!.id} | User Left`);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [channelId, permissions] of permsToSet) {
|
for (const [channelId, permissions] of permsToSet) {
|
||||||
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
|
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
|
||||||
if (!channel || !(channel instanceof TextChannel)) continue;
|
if (!channel || !(channel instanceof TextChannel)) continue;
|
||||||
await channel.updateOverwrite(userId, new Permissions(BigInt(permissions)).serialize(), {
|
await channel.permissionOverwrites.create(userId as Snowflake, new Permissions(BigInt(permissions)).serialize(), {
|
||||||
reason: `Companion Channel for ${voiceChannel!.id} | User Joined`,
|
reason: `Companion Channel for ${voiceChannel!.id} | User Joined`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { Snowflake } from "discord.js";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { canActOn } from "../../../pluginUtils";
|
import { canActOn } from "../../../pluginUtils";
|
||||||
|
@ -30,6 +31,6 @@ export async function addRoleAction(
|
||||||
|
|
||||||
const rolesToAdd = Array.isArray(action.role) ? action.role : [action.role];
|
const rolesToAdd = Array.isArray(action.role) ? action.role : [action.role];
|
||||||
await target.edit({
|
await target.edit({
|
||||||
roles: Array.from(new Set([...target.roles.cache.array(), ...rolesToAdd])),
|
roles: Array.from(new Set([...target.roles.cache.array(), ...rolesToAdd])) as Snowflake[],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Snowflake, TextChannel } from "discord.js";
|
import { Permissions, Snowflake, TextChannel } from "discord.js";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { ActionError } from "../ActionError";
|
import { ActionError } from "../ActionError";
|
||||||
|
@ -31,9 +31,16 @@ export async function setChannelPermissionOverridesAction(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const override of action.overrides) {
|
for (const override of action.overrides) {
|
||||||
await channel.overwritePermissions(
|
channel.permissionOverwrites.create(
|
||||||
|
override.id as Snowflake,
|
||||||
|
new Permissions(BigInt(override.allow)).add(BigInt(override.deny)).serialize(),
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
await channel.permissionOverwrites overwritePermissions(
|
||||||
[{ id: override.id, allow: BigInt(override.allow), deny: BigInt(override.deny), type: override.type }],
|
[{ id: override.id, allow: BigInt(override.allow), deny: BigInt(override.deny), type: override.type }],
|
||||||
`Custom event: ${event.name}`,
|
`Custom event: ${event.name}`,
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Message } from "discord.js";
|
||||||
import { messageSaverEvt } from "../types";
|
import { messageSaverEvt } from "../types";
|
||||||
|
|
||||||
export const MessageCreateEvt = messageSaverEvt({
|
export const MessageCreateEvt = messageSaverEvt({
|
||||||
event: "message",
|
event: "messageCreate",
|
||||||
allowBots: true,
|
allowBots: true,
|
||||||
allowSelf: true,
|
allowSelf: true,
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ export const MutesCmd = mutesCmd({
|
||||||
await listMessage.edit({ components: [row] });
|
await listMessage.edit({ components: [row] });
|
||||||
|
|
||||||
const filter = (iac: MessageComponentInteraction) => iac.message.id === listMessage.id;
|
const filter = (iac: MessageComponentInteraction) => iac.message.id === listMessage.id;
|
||||||
const collector = listMessage.createMessageComponentInteractionCollector({
|
const collector = listMessage.createMessageComponentCollector({
|
||||||
filter,
|
filter,
|
||||||
time: stopCollectionDebounce,
|
time: stopCollectionDebounce,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { Snowflake } from "discord.js";
|
||||||
import { LogType } from "../../../data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
import { stripObjectToScalars } from "../../../utils";
|
import { stripObjectToScalars } from "../../../utils";
|
||||||
import { memberRolesLock } from "../../../utils/lockNameHelpers";
|
import { memberRolesLock } from "../../../utils/lockNameHelpers";
|
||||||
|
@ -15,7 +16,7 @@ export const ReapplyActiveMuteOnJoinEvt = mutesEvt({
|
||||||
|
|
||||||
if (muteRole) {
|
if (muteRole) {
|
||||||
const memberRoleLock = await pluginData.locks.acquire(memberRolesLock(member));
|
const memberRoleLock = await pluginData.locks.acquire(memberRolesLock(member));
|
||||||
await member.roles.add(muteRole);
|
await member.roles.add(muteRole as Snowflake);
|
||||||
memberRoleLock.unlock();
|
memberRoleLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ export async function clearExpiredMutes(pluginData: GuildPluginData<MutesPluginT
|
||||||
|
|
||||||
const muteRole = pluginData.config.get().mute_role;
|
const muteRole = pluginData.config.get().mute_role;
|
||||||
if (muteRole) {
|
if (muteRole) {
|
||||||
await member.roles.remove(muteRole);
|
await member.roles.remove(muteRole as Snowflake);
|
||||||
}
|
}
|
||||||
if (mute.roles_to_restore) {
|
if (mute.roles_to_restore) {
|
||||||
const guildRoles = pluginData.guild.roles.cache;
|
const guildRoles = pluginData.guild.roles.cache;
|
||||||
|
@ -26,7 +26,7 @@ export async function clearExpiredMutes(pluginData: GuildPluginData<MutesPluginT
|
||||||
for (const toRestore of mute.roles_to_restore) {
|
for (const toRestore of mute.roles_to_restore) {
|
||||||
if (guildRoles.has(toRestore as Snowflake) && toRestore !== muteRole) newRoles.push(toRestore);
|
if (guildRoles.has(toRestore as Snowflake) && toRestore !== muteRole) newRoles.push(toRestore);
|
||||||
}
|
}
|
||||||
await member.roles.set(newRoles);
|
await member.roles.set(newRoles as Snowflake[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
|
@ -69,11 +69,11 @@ export async function muteUser(
|
||||||
// exclude managed roles from being removed
|
// exclude managed roles from being removed
|
||||||
const managedRoles = pluginData.guild.roles.cache.filter(x => x.managed).map(y => y.id);
|
const managedRoles = pluginData.guild.roles.cache.filter(x => x.managed).map(y => y.id);
|
||||||
newRoles = currentUserRoles.filter(r => !managedRoles.includes(r));
|
newRoles = currentUserRoles.filter(r => !managedRoles.includes(r));
|
||||||
await member.roles.set(newRoles);
|
await member.roles.set(newRoles as Snowflake[]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newRoles = currentUserRoles.filter(x => !(<string[]>removeRoles).includes(x));
|
newRoles = currentUserRoles.filter(x => !(<string[]>removeRoles).includes(x));
|
||||||
await member.roles.set(newRoles);
|
await member.roles.set(newRoles as Snowflake[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set roles to be restored
|
// set roles to be restored
|
||||||
|
@ -88,7 +88,7 @@ export async function muteUser(
|
||||||
// Apply mute role if it's missing
|
// Apply mute role if it's missing
|
||||||
if (!currentUserRoles.includes(muteRole as Snowflake)) {
|
if (!currentUserRoles.includes(muteRole as Snowflake)) {
|
||||||
try {
|
try {
|
||||||
await member.roles.add(muteRole);
|
await member.roles.add(muteRole as Snowflake);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const actualMuteRole = pluginData.guild.roles.cache.find(x => x.id === muteRole);
|
const actualMuteRole = pluginData.guild.roles.cache.find(x => x.id === muteRole);
|
||||||
if (!actualMuteRole) {
|
if (!actualMuteRole) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ export async function unmuteUser(
|
||||||
|
|
||||||
const muteRole = pluginData.config.get().mute_role;
|
const muteRole = pluginData.config.get().mute_role;
|
||||||
if (muteRole && member.roles.cache.has(muteRole as Snowflake)) {
|
if (muteRole && member.roles.cache.has(muteRole as Snowflake)) {
|
||||||
await member.roles.remove(muteRole);
|
await member.roles.remove(muteRole as Snowflake);
|
||||||
}
|
}
|
||||||
if (existingMute?.roles_to_restore) {
|
if (existingMute?.roles_to_restore) {
|
||||||
const guildRoles = pluginData.guild.roles.cache;
|
const guildRoles = pluginData.guild.roles.cache;
|
||||||
|
@ -46,7 +46,7 @@ export async function unmuteUser(
|
||||||
for (const toRestore of existingMute.roles_to_restore) {
|
for (const toRestore of existingMute.roles_to_restore) {
|
||||||
if (guildRoles.has(toRestore as Snowflake) && toRestore !== muteRole) newRoles.push(toRestore);
|
if (guildRoles.has(toRestore as Snowflake) && toRestore !== muteRole) newRoles.push(toRestore);
|
||||||
}
|
}
|
||||||
await member.roles.set(newRoles);
|
await member.roles.set(newRoles as Snowflake[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
|
@ -15,7 +15,7 @@ export const ChannelJoinEvt = nameHistoryEvt({
|
||||||
});
|
});
|
||||||
|
|
||||||
export const MessageCreateEvt = nameHistoryEvt({
|
export const MessageCreateEvt = nameHistoryEvt({
|
||||||
event: "message",
|
event: "messageCreate",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
meta.pluginData.state.updateQueue.add(() => updateNickname(meta.pluginData, meta.args.message.member!));
|
meta.pluginData.state.updateQueue.add(() => updateNickname(meta.pluginData, meta.args.message.member!));
|
||||||
|
|
|
@ -29,7 +29,7 @@ export const TypingEnablePingableEvt = pingableRolesEvt({
|
||||||
});
|
});
|
||||||
|
|
||||||
export const MessageCreateDisablePingableEvt = pingableRolesEvt({
|
export const MessageCreateDisablePingableEvt = pingableRolesEvt({
|
||||||
event: "message",
|
event: "messageCreate",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
const pluginData = meta.pluginData;
|
const pluginData = meta.pluginData;
|
||||||
|
|
|
@ -80,7 +80,7 @@ export const RoleAddCmd = selfGrantableRolesCmd({
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await msg.member.edit({
|
await msg.member.edit({
|
||||||
roles: Array.from(newRoleIds),
|
roles: Array.from(newRoleIds) as Snowflake[],
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
sendErrorMessage(
|
sendErrorMessage(
|
||||||
|
|
|
@ -11,16 +11,13 @@ export async function applyBotSlowmodeToUserId(
|
||||||
userId: string,
|
userId: string,
|
||||||
) {
|
) {
|
||||||
// Deny sendMessage permission from the user. If there are existing permission overwrites, take those into account.
|
// Deny sendMessage permission from the user. If there are existing permission overwrites, take those into account.
|
||||||
const existingOverride = channel.permissionOverwrites.get(userId as Snowflake);
|
const existingOverride = channel.permissionOverwrites.resolve(userId as Snowflake);
|
||||||
const newDeniedPermissions =
|
|
||||||
(existingOverride ? existingOverride.deny.bitfield : 0n) | Permissions.FLAGS.SEND_MESSAGES;
|
|
||||||
const newAllowedPermissions =
|
|
||||||
(existingOverride ? existingOverride.allow.bitfield : 0n) & ~Permissions.FLAGS.SEND_MESSAGES;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await channel.overwritePermissions([
|
if (existingOverride) {
|
||||||
{ id: userId, allow: newAllowedPermissions, deny: newDeniedPermissions, type: "member" },
|
await existingOverride.edit({ SEND_MESSAGES: false });
|
||||||
]);
|
} else {
|
||||||
|
await channel.permissionOverwrites.create(userId as Snowflake, { SEND_MESSAGES: false }, { type: 1 });
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const user = pluginData.client.users.fetch(userId as Snowflake) || new UnknownUser({ id: userId });
|
const user = pluginData.client.users.fetch(userId as Snowflake) || new UnknownUser({ id: userId });
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ export async function clearBotSlowmodeFromUserId(
|
||||||
// Previously we diffed the overrides so we could clear the "send messages" override without touching other
|
// Previously we diffed the overrides so we could clear the "send messages" override without touching other
|
||||||
// overrides. Unfortunately, it seems that was a bit buggy - we didn't always receive the event for the changed
|
// overrides. Unfortunately, it seems that was a bit buggy - we didn't always receive the event for the changed
|
||||||
// overrides and then we also couldn't diff against them. For consistency's sake, we just delete the override now.
|
// overrides and then we also couldn't diff against them. For consistency's sake, we just delete the override now.
|
||||||
await channel.permissionOverwrites.get(userId as Snowflake)?.delete();
|
await channel.permissionOverwrites.resolve(userId as Snowflake)?.delete();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { usernameSaverEvt } from "../types";
|
||||||
import { updateUsername } from "../updateUsername";
|
import { updateUsername } from "../updateUsername";
|
||||||
|
|
||||||
export const MessageCreateUpdateUsernameEvt = usernameSaverEvt({
|
export const MessageCreateUpdateUsernameEvt = usernameSaverEvt({
|
||||||
event: "message",
|
event: "messageCreate",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
if (meta.args.message.author.bot) return;
|
if (meta.args.message.author.bot) return;
|
||||||
|
|
|
@ -198,7 +198,7 @@ export async function displaySearch(
|
||||||
await searchMsg.edit({ content: result, components: [row] });
|
await searchMsg.edit({ content: result, components: [row] });
|
||||||
|
|
||||||
const filter = (iac: MessageComponentInteraction) => iac.message.id === searchMsg.id;
|
const filter = (iac: MessageComponentInteraction) => iac.message.id === searchMsg.id;
|
||||||
const collector = searchMsg.createMessageComponentInteractionCollector({ filter, time: 2 * MINUTES });
|
const collector = searchMsg.createMessageComponentCollector({ filter, time: 2 * MINUTES });
|
||||||
|
|
||||||
collector.on("collect", async (interaction: MessageComponentInteraction) => {
|
collector.on("collect", async (interaction: MessageComponentInteraction) => {
|
||||||
if (msg.author.id !== interaction.user.id) {
|
if (msg.author.id !== interaction.user.id) {
|
||||||
|
|
|
@ -1,9 +1,18 @@
|
||||||
import { Client, Message, MessageOptions, MessageReaction, PartialUser, TextChannel, User } from "discord.js";
|
import {
|
||||||
|
Client,
|
||||||
|
Message,
|
||||||
|
MessageEditOptions,
|
||||||
|
MessageOptions,
|
||||||
|
MessageReaction,
|
||||||
|
PartialUser,
|
||||||
|
TextChannel,
|
||||||
|
User,
|
||||||
|
} from "discord.js";
|
||||||
import { Awaitable } from "knub/dist/utils";
|
import { Awaitable } from "knub/dist/utils";
|
||||||
import { MINUTES, noop } from "../utils";
|
import { MINUTES, noop } from "../utils";
|
||||||
import Timeout = NodeJS.Timeout;
|
import Timeout = NodeJS.Timeout;
|
||||||
|
|
||||||
export type LoadPageFn = (page: number) => Awaitable<MessageOptions>;
|
export type LoadPageFn = (page: number) => Awaitable<MessageOptions & MessageEditOptions>;
|
||||||
|
|
||||||
export interface PaginateMessageOpts {
|
export interface PaginateMessageOpts {
|
||||||
timeout: number;
|
timeout: number;
|
||||||
|
|
|
@ -23,7 +23,7 @@ export async function waitForButtonConfirm(
|
||||||
const message = await channel.send({ ...toPost, components: [row] });
|
const message = await channel.send({ ...toPost, components: [row] });
|
||||||
|
|
||||||
const filter = (iac: MessageComponentInteraction) => iac.message.id === message.id;
|
const filter = (iac: MessageComponentInteraction) => iac.message.id === message.id;
|
||||||
const collector = message.createMessageComponentInteractionCollector({ filter, time: 10000 });
|
const collector = message.createMessageComponentCollector({ filter, time: 10000 });
|
||||||
|
|
||||||
collector.on("collect", (interaction: MessageComponentInteraction) => {
|
collector.on("collect", (interaction: MessageComponentInteraction) => {
|
||||||
if (options?.restrictToId && options.restrictToId !== interaction.user.id) {
|
if (options?.restrictToId && options.restrictToId !== interaction.user.id) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue