File tree Expand file tree Collapse file tree 3 files changed +7
-9
lines changed
Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -118,12 +118,13 @@ export class DiscordBot extends Service {
118118
119119 // sets both the bot's avatar and the guild's icon
120120 async setIcon (
121- path = this . data ?. lastDiscordGuildIcon ?? "resources/discord-guild-icons/default.png"
121+ path = this . data ?. lastDiscordGuildIcon ?? "resources/discord-guild-icons/default.png" ,
122+ reason ?: string
122123 ) : Promise < boolean > {
123124 if ( ! this . ready || ! this . discord . user ) return false ;
124125 try {
125126 await this . discord . user . setAvatar ( path ) ;
126- await this . getGuild ( ) ?. setIcon ( path ) ;
127+ await this . getGuild ( ) ?. setIcon ( path , reason ) ;
127128 if ( this . data ) {
128129 this . data . lastDiscordGuildIcon = path ;
129130 await this . data . save ( ) ;
Original file line number Diff line number Diff line change @@ -67,7 +67,6 @@ export default async (bot: DiscordBot): Promise<void> => {
6767 if ( match ) {
6868 const path = join ( iconsPath , `${ icon } .png` ) ;
6969 await bot . setIcon ( path ) ;
70- await bot . discord . user ?. setAvatar ( path ) ;
7170 await bot . setNickname (
7271 nicks [ ( Math . random ( ) * nicks . length ) | 0 ] ,
7372 event . name
Original file line number Diff line number Diff line change @@ -45,10 +45,10 @@ const fileExists = async (filePath: PathLike) =>
4545 . catch ( ( ) => false ) ;
4646
4747export default async ( bot : DiscordBot ) : Promise < void > => {
48- const data = await bot . container . getService ( "Data" ) ;
4948 bot . discord . on ( "ready" , async ( ) => {
5049 const guild = bot . getGuild ( ) ;
5150 if ( ! guild ) return ;
51+ const data = await bot . container . getService ( "Data" ) ;
5252
5353 const changeIcon = async ( filePath : string , eventName : string ) => {
5454 const eventChange = data . lastDiscordGuildEvent !== eventName ;
@@ -57,21 +57,19 @@ export default async (bot: DiscordBot): Promise<void> => {
5757
5858 if ( eventChange && ! guildEvents . find ( ev => ev . isActive ( ) ) ) {
5959 try {
60- await guild . setIcon (
60+ await bot . setIcon (
6161 filePath ,
6262 eventName !== "None"
6363 ? `It's ${ eventName } !`
6464 : "Back to regularly scheduled activities."
6565 ) ;
66- await bot . discord . user ?. setAvatar ( filePath ) ;
67- data . lastDiscordGuildIcon = filePath ;
66+ data . lastDiscordGuildEvent = eventName ;
67+ await data . save ( ) ;
6868 } catch ( err ) {
6969 console . error ( err ) ;
7070 return ;
7171 }
72- data . lastDiscordGuildEvent = eventName ;
7372 }
74- await data . save ( ) ;
7573 } ;
7674
7775 const checkDate = async ( ) => {
You can’t perform that action at this time.
0 commit comments