decord/source/actions/ChangeVanityURLActionCreators.tsx

57 lines
2.3 KiB
TypeScript
Raw Normal View History

// Module ID: 17731
// Function ID: 17732
// Name: ChangeVanityURLActionCreators
// Dependencies: [1074, 573, 1272, 2]
2026-07-20 16:05:17 +00:00
// Module 17731 (ChangeVanityURLActionCreators)
import DispatcherDefault from "Dispatcher" /* 573 */;
import Constants from "Constants" /* 1074 */;
import HTTPUtils from "HTTPUtils" /* 1272 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
const Endpoints = Constants.Endpoints;
const result = size.fileFinishedImporting("actions/ChangeVanityURLActionCreators.tsx");
2026-07-20 16:05:17 +00:00
export default {
openModal(id, vanityURLCode) {
DispatcherDefault.dispatch({ type: "CHANGE_VANITY_URL_MODAL_OPEN", guildId: id, code: vanityURLCode });
2026-07-20 16:05:17 +00:00
},
closeModal() {
DispatcherDefault.dispatch({ type: "CHANGE_VANITY_URL_MODAL_CLOSE" });
2026-07-20 16:05:17 +00:00
},
removeVanityURL(id) {
const HTTP = HTTPUtils.HTTP;
const request = { url: Endpoints.GUILD_VANITY_URL(id), body: { code: null }, oldFormErrors: true, rejectWithError: true };
return HTTP.patch(request).then(() => {
DispatcherDefault.dispatch({ type: "GUILD_SETTINGS_SET_VANITY_URL", code: null, uses: 0 });
2026-07-20 16:05:17 +00:00
});
},
changeVanityURL(id, vanityURLCode) {
2026-07-23 10:11:24 +00:00
const self = this;
DispatcherDefault.dispatch({ type: "CHANGE_VANITY_URL_MODAL_SUBMIT" });
const HTTP = self(1272).HTTP;
const request = { url: Endpoints.GUILD_VANITY_URL(id), body: { code: vanityURLCode }, oldFormErrors: true, rejectWithError: true };
const obj2 = { code: vanityURLCode };
return HTTP.patch(request).then((body) => {
2026-07-20 16:05:17 +00:00
({ code, uses } = body.body);
DispatcherDefault.dispatch({ type: "GUILD_SETTINGS_SET_VANITY_URL", code, uses });
2026-07-20 16:05:17 +00:00
self.closeModal();
}, (body) => {
DispatcherDefault.dispatch({ type: "CHANGE_VANITY_URL_MODAL_SUBMIT_FAILURE", error: body.body, hasError: true });
2026-07-20 16:05:17 +00:00
return body;
});
},
setVanityURL(id, code) {
const HTTP = HTTPUtils.HTTP;
const request = { url: Endpoints.GUILD_VANITY_URL(id), body: { code }, oldFormErrors: true, rejectWithError: HTTPUtils.rejectWithMigratedError() };
const obj = { code };
return HTTP.patch(request).then((body) => {
2026-07-20 16:05:17 +00:00
({ code, uses } = body.body);
DispatcherDefault.dispatch({ type: "GUILD_SETTINGS_SET_VANITY_URL", code, uses });
2026-07-20 16:05:17 +00:00
}, (body) => {
DispatcherDefault.dispatch({ type: "CHANGE_VANITY_URL_MODAL_SUBMIT_FAILURE", error: body.body, hasError: true });
2026-07-20 16:05:17 +00:00
return body;
});
}
};