Add auth to the server injection and adjust channel ID storage
This commit is contained in:
parent
1819bd993e
commit
845aa7c1ae
1 changed files with 8 additions and 11 deletions
|
|
@ -8,18 +8,14 @@ export default {
|
||||||
async handler(request: Request, h: ResponseToolkit) {
|
async handler(request: Request, h: ResponseToolkit) {
|
||||||
let gID = request.params.guild_id;
|
let gID = request.params.guild_id;
|
||||||
|
|
||||||
let r = await request.server.inject(`/${gID}/bracket/winners`);
|
let r = await request.server.inject({
|
||||||
|
url: `/${gID}/bracket/winners`,
|
||||||
|
auth: request.auth,
|
||||||
|
});
|
||||||
let data = JSON.parse(r.payload);
|
let data = JSON.parse(r.payload);
|
||||||
|
|
||||||
if (data.count >= 2) {
|
if (data.count >= 2) {
|
||||||
|
|
||||||
// Get the webhook's current information
|
|
||||||
let wh = db[gID].webhook;
|
|
||||||
let r = await axios.get(
|
|
||||||
`${DISCORD_API_URI}/webhooks/${wh.id}/${wh.token}`
|
|
||||||
);
|
|
||||||
let { channel_id } = r.data;
|
|
||||||
|
|
||||||
// Construct the primary body of the message
|
// Construct the primary body of the message
|
||||||
let content = `The bracket currently has a tie between:\n> ${data.winners.join('\n~~------------------------------------~~\n> ')}`;
|
let content = `The bracket currently has a tie between:\n> ${data.winners.join('\n~~------------------------------------~~\n> ')}`;
|
||||||
|
|
||||||
|
|
@ -31,11 +27,12 @@ export default {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add link if we know what channel the message was posted in
|
// Add link if we know what channel the message was posted in
|
||||||
if (channel_id) {
|
if (db[gID].bracket.channel) {
|
||||||
content += `\n\n[Jump To Bracket](https://discord.com/${gID}/${channel_id}/${db[gID].bracket.msg})`
|
content += `\n\n[Jump To Bracket](https://discord.com/channels/${gID}/${db[gID].bracket.channel}/${db[gID].bracket.msg})`
|
||||||
};
|
};
|
||||||
|
|
||||||
r = await axios.post(
|
let wh = db[gID].webhook;
|
||||||
|
let r = await axios.post(
|
||||||
`${DISCORD_API_URI}/webhooks/${wh.id}/${wh.token}`,
|
`${DISCORD_API_URI}/webhooks/${wh.id}/${wh.token}`,
|
||||||
{ content },
|
{ content },
|
||||||
{ params: { wait: true } }
|
{ params: { wait: true } }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue