// Metro module 15670 (f15671). import { AbortCodes, Endpoints } from "../Constants"; import Dispatcher from "../Dispatcher"; import { HTTP, rejectWithMigratedError } from "../_bundle/sendRequest"; import Module12 from "../_bundle/Module12"; import AlertActionCreators from "./AlertActionCreators"; import { intl, t } from "../intl/index.native"; const _excluded = ["Spidey Bot", "Captain Hook"]; const r18 = { fetchForGuild: (a0) => { const guildId = a0; Dispatcher.dispatch({ type: "WEBHOOKS_FETCHING", guildId: a0 }); HTTP.get({ url: Endpoints.GUILD_WEBHOOKS(a0), oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then((result) => Dispatcher.dispatch({ type: "WEBHOOKS_UPDATE", guildId, webhooks: result.body })).catch((a0) => { Dispatcher.dispatch({ type: "WEBHOOKS_UPDATE", guildId, error: a0.body.message }); }); }, fetchForChannel: (a0, a1) => { const guildId2 = a0; const channelId = a1; Dispatcher.dispatch({ type: "WEBHOOKS_FETCHING", guildId: a0, channelId: a1 }); HTTP.get({ url: Endpoints.CHANNEL_WEBHOOKS(a1), oldFormErrors: true, rejectWithError: true }).then((result) => Dispatcher.dispatch({ type: "WEBHOOKS_UPDATE", guildId: guildId2, channelId, webhooks: result.body })).catch((a0) => { Dispatcher.dispatch({ type: "WEBHOOKS_UPDATE", guildId: guildId2, error: a0.body.message }); }); }, create: (guildId3, a1, a2) => { const name = a2 == null ? _excluded[Module12.random(0, _excluded.length - 1)] : a2; return HTTP.post({ url: Endpoints.CHANNEL_WEBHOOKS(a1), body: { name }, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then(({ body }) => { Dispatcher.dispatch({ type: "WEBHOOK_CREATE", guildId: guildId3, webhook: body }); return body; }).catch(({ body, status }) => { if (body != null && body.code === AbortCodes.TOO_MANY_WEBHOOKS) { AlertActionCreators.show({ title: intl.string(t.cCqsca), body: intl.string(t["w+QZoX"]) }); } else if (status === 429) { AlertActionCreators.show({ title: intl.string(t.cCqsca), body: intl.string(t["YBM+UW"]) }); } else { AlertActionCreators.show({ title: intl.string(t.cCqsca), body: intl.string(t["/4TwKf"]) }); } return null; }); }, delete: (guildId4, a1) => { const webhookId = a1; return HTTP.del({ url: Endpoints.WEBHOOK(a1), oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then(() => { Dispatcher.dispatch({ type: "WEBHOOK_DELETE", guildId: guildId4, webhookId }); }); }, update: (guildId5, a1, a2) => HTTP.patch({ url: Endpoints.WEBHOOK(a1), body: a2, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then(({ body }) => { Dispatcher.dispatch({ type: "WEBHOOK_UPDATE", guildId: guildId5, webhook: body }); return body; }) }; export default r18;