bug fixes
This commit is contained in:
@@ -87,6 +87,12 @@ async function listInvites(guildId) {
|
||||
return json || [];
|
||||
}
|
||||
|
||||
async function listReactionRoles(guildId) {
|
||||
const path = `/api/servers/${guildId}/reaction-roles`;
|
||||
const json = await safeFetchJsonPath(path);
|
||||
return json || [];
|
||||
}
|
||||
|
||||
async function addInvite(guildId, invite) {
|
||||
const path = `/api/servers/${guildId}/invites`;
|
||||
try {
|
||||
@@ -127,6 +133,33 @@ async function deleteInvite(guildId, code) {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateReactionRole(guildId, id, updates) {
|
||||
const path = `/api/servers/${guildId}/reaction-roles/${id}`;
|
||||
try {
|
||||
const res = await tryFetch(path, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(updates),
|
||||
});
|
||||
if (!res) return null;
|
||||
try { return await res.json(); } catch (e) { return null; }
|
||||
} catch (e) {
|
||||
console.error(`Failed to update reaction role ${id} for ${guildId}:`, e && e.message ? e.message : e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteReactionRole(guildId, id) {
|
||||
const path = `/api/servers/${guildId}/reaction-roles/${id}`;
|
||||
try {
|
||||
const res = await tryFetch(path, { method: 'DELETE' });
|
||||
return res && res.ok;
|
||||
} catch (e) {
|
||||
console.error(`Failed to delete reaction role ${id} for ${guildId}:`, e && e.message ? e.message : e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { getServerSettings, upsertServerSettings, getCommands, toggleCommand, listInvites, addInvite, deleteInvite };
|
||||
// Twitch users helpers
|
||||
async function getTwitchUsers(guildId) {
|
||||
@@ -262,4 +295,4 @@ async function reconcileInvites(guildId, currentDiscordInvites) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { getServerSettings, upsertServerSettings, getCommands, toggleCommand, listInvites, addInvite, deleteInvite, getTwitchUsers, addTwitchUser, deleteTwitchUser, tryFetchTwitchStreams, _rawGetTwitchStreams, getKickUsers, addKickUser, deleteKickUser, getWelcomeLeaveSettings, getAutoroleSettings, reconcileInvites };
|
||||
module.exports = { getServerSettings, upsertServerSettings, getCommands, toggleCommand, listInvites, addInvite, deleteInvite, listReactionRoles, updateReactionRole, deleteReactionRole, getTwitchUsers, addTwitchUser, deleteTwitchUser, tryFetchTwitchStreams, _rawGetTwitchStreams, getKickUsers, addKickUser, deleteKickUser, getWelcomeLeaveSettings, getAutoroleSettings, reconcileInvites };
|
||||
|
||||
Reference in New Issue
Block a user