Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4943.js (118.4 MB)
109 lines
4.7 KiB
TypeScript
109 lines
4.7 KiB
TypeScript
// Module ID: 17314
|
|
// Function ID: 17315
|
|
// Name: WebhooksActionCreators
|
|
// Dependencies: [1078, 577, 1275, 12, 5110, 1119, 2]
|
|
|
|
// Module 17314 (WebhooksActionCreators)
|
|
import _modDef12 from "module_12" /* 12 */;
|
|
import DispatcherDefault from "Dispatcher" /* 577 */;
|
|
import AlertActionCreatorsDefault from "AlertActionCreators" /* 5110 */;
|
|
import Constants from "Constants" /* 1078 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
const require = globalThis.__r;
|
|
|
|
({ AbortCodes: c3, Endpoints: closure_4 } = Constants);
|
|
const result = size.fileFinishedImporting("actions/WebhooksActionCreators.tsx");
|
|
|
|
export default {
|
|
fetchForGuild(id) {
|
|
_require = id;
|
|
DispatcherDefault.dispatch({ type: "WEBHOOKS_FETCHING", guildId: id });
|
|
const HTTP = require("HTTPUtils").HTTP;
|
|
const obj3 = { url: closure_4.GUILD_WEBHOOKS(id), oldFormErrors: true, rejectWithError: null };
|
|
const obj2 = { type: "WEBHOOKS_FETCHING", guildId: id };
|
|
obj3.rejectWithError = require("HTTPUtils").rejectWithMigratedError();
|
|
value = HTTP.get(obj3);
|
|
const obj4 = require("HTTPUtils");
|
|
value.then((body) => DispatcherDefault.dispatch({ type: "WEBHOOKS_UPDATE", guildId, webhooks: body.body })).catch((error) => {
|
|
DispatcherDefault.dispatch({ type: "WEBHOOKS_UPDATE", guildId, error: error.body.message });
|
|
});
|
|
},
|
|
fetchForChannel(id, channelId) {
|
|
_require = id;
|
|
importDefault = channelId;
|
|
DispatcherDefault.dispatch({ type: "WEBHOOKS_FETCHING", guildId: id, channelId });
|
|
const HTTP = require("HTTPUtils").HTTP;
|
|
const obj2 = { type: "WEBHOOKS_FETCHING", guildId: id, channelId };
|
|
value = HTTP.get({ url: closure_4.CHANNEL_WEBHOOKS(channelId), oldFormErrors: true, rejectWithError: true });
|
|
const obj3 = { url: closure_4.CHANNEL_WEBHOOKS(channelId), oldFormErrors: true, rejectWithError: true };
|
|
value.then((body) => DispatcherDefault.dispatch({ type: "WEBHOOKS_UPDATE", guildId, channelId, webhooks: body.body })).catch((error) => {
|
|
DispatcherDefault.dispatch({ type: "WEBHOOKS_UPDATE", guildId, error: error.body.message });
|
|
});
|
|
},
|
|
create(guildId, channelId, arg2) {
|
|
_require = guildId;
|
|
let tmp = arg2;
|
|
if (null == arg2) {
|
|
let obj = _modDef12;
|
|
tmp = length[obj.random(obj, 0, length.length - 1)];
|
|
}
|
|
const HTTP = require("HTTPUtils").HTTP;
|
|
const request = { url: closure_4.CHANNEL_WEBHOOKS(channelId), body: { name: tmp }, oldFormErrors: true, rejectWithError: require("HTTPUtils").rejectWithMigratedError() };
|
|
let obj3 = require("HTTPUtils");
|
|
const postResult = HTTP.post(request);
|
|
return HTTP.post(request).then((body) => {
|
|
body = body.body;
|
|
DispatcherDefault.dispatch({ type: "WEBHOOK_CREATE", guildId, webhook: body });
|
|
return body;
|
|
}).catch((error) => {
|
|
const body = error.body;
|
|
if (null != body) {
|
|
if (body.code === constants.TOO_MANY_WEBHOOKS) {
|
|
const obj2 = { title: null, body: null };
|
|
const intl3 = guildId(1119).intl;
|
|
obj2.title = intl3.string(guildId(1119).t.cCqsca);
|
|
const intl4 = guildId(1119).intl;
|
|
obj2.body = intl4.string(guildId(1119).t["w+QZoX"]);
|
|
AlertActionCreatorsDefault.show(obj2);
|
|
}
|
|
return null;
|
|
}
|
|
if (429 === error.status) {
|
|
const obj4 = { title: null, body: null };
|
|
const intl = guildId(1119).intl;
|
|
obj4.title = intl.string(guildId(1119).t.cCqsca);
|
|
const intl2 = guildId(1119).intl;
|
|
obj4.body = intl2.string(guildId(1119).t["YBM+UW"]);
|
|
AlertActionCreatorsDefault.show(obj4);
|
|
} else {
|
|
const obj6 = { title: null, body: null };
|
|
const intl5 = guildId(1119).intl;
|
|
obj6.title = intl5.string(guildId(1119).t.cCqsca);
|
|
const intl6 = guildId(1119).intl;
|
|
obj6.body = intl6.string(guildId(1119).t["/4TwKf"]);
|
|
AlertActionCreatorsDefault.show(obj6);
|
|
}
|
|
});
|
|
},
|
|
delete(guildId, webhookId) {
|
|
_require = guildId;
|
|
const HTTP = require("HTTPUtils").HTTP;
|
|
const obj = { url: closure_4.WEBHOOK(webhookId), oldFormErrors: true, rejectWithError: require("HTTPUtils").rejectWithMigratedError() };
|
|
const obj2 = require("HTTPUtils");
|
|
return HTTP.del(obj).then(() => {
|
|
DispatcherDefault.dispatch({ type: "WEBHOOK_DELETE", guildId, webhookId });
|
|
});
|
|
},
|
|
update(guildId, arg1, body) {
|
|
_require = guildId;
|
|
const HTTP = require("HTTPUtils").HTTP;
|
|
const request = { url: closure_4.WEBHOOK(arg1), body, oldFormErrors: true, rejectWithError: require("HTTPUtils").rejectWithMigratedError() };
|
|
const obj2 = require("HTTPUtils");
|
|
return HTTP.patch(request).then((body) => {
|
|
body = body.body;
|
|
DispatcherDefault.dispatch({ type: "WEBHOOK_UPDATE", guildId, webhook: body });
|
|
return body;
|
|
});
|
|
}
|
|
};
|