Files
discord-decomp/actions/ChangeVanityURLActionCreators.tsx
T
2026-11-01 12:12:55 +02:00

82 lines
1.9 KiB
TypeScript

// Metro module 16484 (f16485).
import { Endpoints } from "../Constants";
import Dispatcher from "../Dispatcher";
import { HTTP, rejectWithMigratedError } from "../_bundle/sendRequest";
const r16 = {
openModal: (a0, a1) => {
Dispatcher.dispatch({
type: "CHANGE_VANITY_URL_MODAL_OPEN",
guildId: a0,
code: a1
});
},
closeModal: () => {
Dispatcher.dispatch({
type: "CHANGE_VANITY_URL_MODAL_CLOSE"
});
},
removeVanityURL: (a0) => HTTP.patch({
url: Endpoints.GUILD_VANITY_URL(a0),
body: {
code: null
},
oldFormErrors: true,
rejectWithError: true
}).then(() => {
Dispatcher.dispatch({
type: "GUILD_SETTINGS_SET_VANITY_URL",
code: null,
uses: 0
});
}),
changeVanityURL: function changeVanityURL(a0, a1) {
Dispatcher.dispatch({
type: "CHANGE_VANITY_URL_MODAL_SUBMIT"
});
return HTTP.patch({
url: Endpoints.GUILD_VANITY_URL(a0),
body: {
code: a1
},
oldFormErrors: true,
rejectWithError: true
}).then(({ body }) => {
Dispatcher.dispatch({
type: "GUILD_SETTINGS_SET_VANITY_URL",
code: body.code,
uses: body.uses
});
this.closeModal();
}, (a0) => {
Dispatcher.dispatch({
type: "CHANGE_VANITY_URL_MODAL_SUBMIT_FAILURE",
error: a0.body,
hasError: true
});
return a0;
});
},
setVanityURL: (a0, a1) => HTTP.patch({
url: Endpoints.GUILD_VANITY_URL(a0),
body: {
code: a1
},
oldFormErrors: true,
rejectWithError: rejectWithMigratedError()
}).then(({ body }) => {
Dispatcher.dispatch({
type: "GUILD_SETTINGS_SET_VANITY_URL",
code: body.code,
uses: body.uses
});
}, (a0) => {
Dispatcher.dispatch({
type: "CHANGE_VANITY_URL_MODAL_SUBMIT_FAILURE",
error: a0.body,
hasError: true
});
return a0;
})
};
export default r16;