problem with permissions
This commit is contained in:
parent
77f66c9672
commit
c82218eb8a
@ -1,6 +1,6 @@
|
|||||||
// Modul dedikovaný funkci spinkáček
|
// Modul dedikovaný funkci spinkáček
|
||||||
|
|
||||||
import { Guild, GuildMember, Message, VoiceState } from "discord.js";
|
import { GuildMember, Message, Role, VoiceState } from "discord.js";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { emouty } from "../utils/emotes";
|
import { emouty } from "../utils/emotes";
|
||||||
import { Spinkackar } from "../utils/types";
|
import { Spinkackar } from "../utils/types";
|
||||||
@ -141,14 +141,22 @@ module.exports = {
|
|||||||
const c = guild.roles.cache;
|
const c = guild.roles.cache;
|
||||||
const spinkRole = c.find(r => r.name == "spink");
|
const spinkRole = c.find(r => r.name == "spink");
|
||||||
const adminRole = c.find(r => r.name == "admin");
|
const adminRole = c.find(r => r.name == "admin");
|
||||||
const mr = member.roles;
|
|
||||||
|
const make = (akce: "a" | "r", role: Role) => {
|
||||||
|
const handle = (e: Error) => {
|
||||||
|
if (e.message == "Missing Permissions") return;
|
||||||
|
console.log("chyba pri davani/odebirani role", e);
|
||||||
|
};
|
||||||
|
if (akce == "a") member.roles.add(role).catch(handle);
|
||||||
|
else member.roles.remove(role).catch(handle);
|
||||||
|
};
|
||||||
|
|
||||||
if (mes.content[0] == "s") {
|
if (mes.content[0] == "s") {
|
||||||
if (spinkRole) mr.add(spinkRole);
|
if (spinkRole) make("a", spinkRole);
|
||||||
if (adminRole) mr.remove(adminRole);
|
if (adminRole) make("r", adminRole);
|
||||||
} else {
|
} else {
|
||||||
if (spinkRole) mr.remove(spinkRole);
|
if (spinkRole) make("a", spinkRole);
|
||||||
if (adminRole) mr.add(adminRole);
|
if (adminRole) make("r", adminRole);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (const [_, channel] of guild.channels.cache) {
|
for (const [_, channel] of guild.channels.cache) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user