-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from zhiyan114/master
Expanding Span tracing slowly..
- Loading branch information
Showing
6 changed files
with
248 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,40 @@ | ||
import { ButtonInteraction, GuildMember } from "discord.js"; | ||
import { DiscordClient } from "../../core/DiscordClient"; | ||
import { DiscordUser } from "../../utils/DiscordUser"; | ||
import { startSpan } from "@sentry/node"; | ||
|
||
export async function VertificationHandler(client: DiscordClient, interaction: ButtonInteraction) { | ||
if(interaction.user.bot) | ||
return interaction.reply({ content: "PRIVILEGE INSUFFICIENT!", ephemeral: true }); | ||
|
||
const user = new DiscordUser(client, interaction.user); | ||
const member = interaction.member as GuildMember | null; | ||
if(!member) return; | ||
await startSpan({ | ||
name: "Discord Verification Handler", | ||
op: "discord.verify", | ||
parentSpan: null | ||
}, async () => { | ||
const user = new DiscordUser(client, interaction.user); | ||
const member = interaction.member as GuildMember | null; | ||
if(!member) return; | ||
|
||
// Check is already verified | ||
const newUserRole = client.config.newUserRoleID; | ||
if(member.roles.cache.has(newUserRole) && await user.isVerified()) | ||
return interaction.reply({ content: "You are already verified!", ephemeral: true }); | ||
// Check is already verified | ||
const newUserRole = client.config.newUserRoleID; | ||
if(member.roles.cache.has(newUserRole) && await user.isVerified()) | ||
return await interaction.reply({ content: "You are already verified!", ephemeral: true }); | ||
|
||
// Update the user | ||
await member.roles.add(newUserRole, "Confirmation Role"); | ||
await user.updateUserData({ rulesconfirmedon: new Date() }); | ||
await startSpan({ | ||
name: "Update Verification Status", | ||
op: "event.helper.VertificationHandler", | ||
}, async()=>{ | ||
// Update the user | ||
await member.roles.add(newUserRole, "Confirmation Role"); | ||
await user.updateUserData({ rulesconfirmedon: new Date() }); | ||
|
||
// Send the message | ||
await interaction.reply({ content: "Thank you for confirming the rules.", ephemeral: true }); | ||
await client.logger.sendLog({ | ||
type: "Interaction", | ||
message: `**${interaction.user.tag}** has confirmed the rules.` | ||
// Send the message | ||
await interaction.reply({ content: "Thank you for confirming the rules.", ephemeral: true }); | ||
await client.logger.sendLog({ | ||
type: "Interaction", | ||
message: `**${interaction.user.tag}** has confirmed the rules.` | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.