mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Add autorole system
See https://lists.sr.ht/~keanucode/travbot-v3/%3C20210815204227.2899-1-lexisoth2005%40gmail.com%3E/raw
This commit is contained in:
		
							parent
							
								
									73278b7e88
								
							
						
					
					
						commit
						985db250d9
					
				
					 3 changed files with 32 additions and 1 deletions
				
			
		|  | @ -61,6 +61,31 @@ export default new NamedCommand({ | |||
|                         }) | ||||
|                     }) | ||||
|                 }), | ||||
|                 autoroles: new NamedCommand({ | ||||
|                     description: "Configure your server's autoroles.", | ||||
|                     usage: "<roles...>", | ||||
|                     async run({send, guild}) { | ||||
|                         Storage.getGuild(guild!.id).autoRoles = []; | ||||
|                         Storage.save(); | ||||
|                         send("Reset this server's autoroles."); | ||||
|                     }, | ||||
|                     id: "role", | ||||
|                     any: new RestCommand({ | ||||
|                         description: "The roles to set as autoroles.", | ||||
|                         async run({send, guild, args}) { | ||||
|                             const guildd = Storage.getGuild(guild!.id); | ||||
|                             for (const role of args) { | ||||
|                                 if (!role.toString().match(/^<@&(\d{17,})>$/)) { | ||||
|                                     return send("Not all arguments are a role mention!"); | ||||
|                                 } | ||||
|                                 const id = role.toString().match(/^<@&(\d{17,})>$/)![1]; | ||||
|                                 guildd.autoRoles!.push(id); | ||||
|                             } | ||||
|                             Storage.save(); | ||||
|                             return send("Saved."); | ||||
|                         } | ||||
|                     }) | ||||
|                 }), | ||||
|                 welcome: new NamedCommand({ | ||||
|                     description: "Configure your server's welcome settings for the bot.", | ||||
|                     usage: "type/channel <...>", | ||||
|  |  | |||
|  | @ -16,7 +16,11 @@ function applyText(canvas: Canvas, text: string) { | |||
| } | ||||
| 
 | ||||
| client.on("guildMemberAdd", async (member) => { | ||||
|     const {welcomeType, welcomeChannel, welcomeMessage} = Storage.getGuild(member.guild.id); | ||||
|     const {welcomeType, welcomeChannel, welcomeMessage, autoRoles} = Storage.getGuild(member.guild.id); | ||||
| 
 | ||||
|     if (autoRoles) { | ||||
|         member.roles.add(autoRoles); | ||||
|     } | ||||
| 
 | ||||
|     if (welcomeChannel) { | ||||
|         const channel = member.guild.channels.cache.get(welcomeChannel); | ||||
|  |  | |||
|  | @ -82,6 +82,7 @@ class Guild { | |||
|     public welcomeType: "none" | "text" | "graphical"; | ||||
|     public welcomeChannel: string | null; | ||||
|     public welcomeMessage: string | null; | ||||
|     public autoRoles: string[] | null; // StringArray of role IDs
 | ||||
|     public streamingChannel: string | null; | ||||
|     public streamingRoles: {[role: string]: string}; // Role ID: Category Name
 | ||||
|     public channelNames: {[channel: string]: string}; | ||||
|  | @ -91,6 +92,7 @@ class Guild { | |||
|         this.prefix = select(data?.prefix, null, String); | ||||
|         this.welcomeChannel = select(data?.welcomeChannel, null, String); | ||||
|         this.welcomeMessage = select(data?.welcomeMessage, null, String); | ||||
|         this.autoRoles = select(data?.autoRoles, null, String, true); | ||||
|         this.streamingChannel = select(data?.streamingChannel, null, String); | ||||
|         this.streamingRoles = {}; | ||||
|         this.channelNames = {}; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue