File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 27
27
secrets : |
28
28
DISCORD_PUBLIC_KEY
29
29
DISCORD_TOKEN
30
+ DISCORD_GUILD_ID
30
31
CURRENT_ENVIRONMENT
31
32
BOT_PRIVATE_KEY
32
33
env :
35
36
DISCORD_PUBLIC_KEY : ${{secrets.DISCORD_PUBLIC_KEY}}
36
37
DISCORD_TOKEN : ${{secrets.DISCORD_TOKEN}}
37
38
BOT_PRIVATE_KEY : ${{secrets.BOT_PRIVATE_KEY}}
39
+ DISCORD_GUILD_ID : ${{secrets.DISCORD_GUILD_ID}}
Original file line number Diff line number Diff line change 27
27
secrets : |
28
28
DISCORD_PUBLIC_KEY
29
29
DISCORD_TOKEN
30
+ DISCORD_GUILD_ID
30
31
CURRENT_ENVIRONMENT
31
32
BOT_PRIVATE_KEY
32
33
env :
35
36
DISCORD_PUBLIC_KEY : ${{secrets.DISCORD_PUBLIC_KEY}}
36
37
DISCORD_TOKEN : ${{secrets.DISCORD_TOKEN}}
37
38
BOT_PRIVATE_KEY : ${{secrets.BOT_PRIVATE_KEY}}
39
+ DISCORD_GUILD_ID : ${{secrets.DISCORD_GUILD_ID}}
Original file line number Diff line number Diff line change @@ -15,3 +15,6 @@ export const STATUS_CHECK = {
15
15
} ;
16
16
17
17
export const COMMAND_NOT_FOUND = "Command Not Found" ;
18
+
19
+ export const INTERNAL_SERVER_ERROR =
20
+ "Oops! We have encountered an internal Server Error" ;
Original file line number Diff line number Diff line change
1
+ import { INTERNAL_SERVER_ERROR } from "../constants/responses" ;
2
+ import { DISCORD_BASE_URL } from "../constants/urls" ;
3
+ import { env } from "../typeDefinitions/default.types" ;
4
+
5
+ export async function updateNickName (
6
+ discordId : string ,
7
+ nickname : string ,
8
+ env : env
9
+ ) {
10
+ const changeNickNameURL = `${ DISCORD_BASE_URL } /guilds/${ env . DISCORD_GUILD_ID } /members/${ discordId } ` ;
11
+ const data = { nick : nickname } ;
12
+ try {
13
+ const nameChangeResponse = await fetch ( changeNickNameURL , {
14
+ method : "PATCH" ,
15
+ headers : {
16
+ "Content-Type" : "application/json" ,
17
+ Authorization : `Bot ${ env . DISCORD_TOKEN } ` ,
18
+ } ,
19
+ body : JSON . stringify ( data ) ,
20
+ } ) ;
21
+ if ( nameChangeResponse . ok ) {
22
+ return await nameChangeResponse . json ( ) ;
23
+ } else {
24
+ console . log ( nameChangeResponse . json ( ) ) ;
25
+ return INTERNAL_SERVER_ERROR ;
26
+ }
27
+ } catch ( error ) {
28
+ console . log ( error ) ;
29
+ return INTERNAL_SERVER_ERROR ;
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments