Last active
August 27, 2022 16:37
-
-
Save velddev/be2e51a9be002093eb14c10f11900c5c to your computer and use it in GitHub Desktop.
verify miki custom command
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
// If the user is already verified and has the verified role, we do not need them to verify again | |
if (author.roles.has(664058556244557844)) then | |
say("you are already verified :)"); | |
stop(); | |
end | |
// all characters that will be used to create the verification code. | |
var codeList = ["A", "B", "C", "D", "E", "F", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]; | |
// this is a specific feature in miscript that will keep your variable alive after the commend finishes running! | |
shared var verifications = {} | |
// check if the user added any arguments after the command | |
if(args.length == 0) then | |
// this creates a new code of 5 characters. | |
// we use the range operator to create a new empty array of 5 elements | |
var code = (1..5).map(() => codeList.random()).join(""); | |
// use the shared variable to register this user's code | |
verifications[author.id] = code | |
say( | |
embed("Please verify that you are a human by using the verify command followed by the code: $[code].") | |
.title("⚠️ verification required!") | |
.color("yellow") | |
); | |
// if the user does have any arguments, we can check if this matches the verification code we set in the previous command | |
else if(args == verifications[author.id]) then | |
// if it does match, give the role to the user :) | |
author.roles.add(664058556244557844); | |
say( | |
embed("Thank you, you have been verified!") | |
.color("green") | |
); | |
// and to make sure we don't leave their session in the storage, we can safely delete it now! | |
verifications.del(author.id); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment