-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
21 lines (18 loc) · 972 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const { default: axios } = require('axios')
async function setVanity({ client: client, guild: guild, code: code }) {
if (!client) throw Error('You need to define client')
if (!guild) throw Error('You need to provide guild id')
if (!code) throw Error('You need to provide vanity code')
const { data, status, statusText } = await axios(
{
url: `https://discord.com/api/v9/guilds/${guild}/vanity-url`,
method: "put",
headers: { "Authorization": `Bot ${client.token}` },
data: { "code": code }
}
)
if (data.code === 50020 && data.message === "Invite code is either invalid or taken.") throw Error('Provided vanity is already used!')
if (data.code === 50001 && data.message === "Missing Access") throw Error('Provided server not have vanity feature!')
if (data.code === 200) throw new Error(`Vanity changed: ${code}`)
}
module.exports.setVanity = setVanity