mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Fixed .eco embeds.
This commit is contained in:
		
							parent
							
								
									3751d01756
								
							
						
					
					
						commit
						8093224c46
					
				
					 4 changed files with 83 additions and 50 deletions
				
			
		|  | @ -39,11 +39,14 @@ export const BetCommand = new NamedCommand({ | |||
|                     // handle invalid amount
 | ||||
|                     if (amount <= 0) return send("You must bet at least one Mon!"); | ||||
|                     else if (sender.money < amount) | ||||
|                         return send({content: "You don't have enough Mons for that.", embeds: [getMoneyEmbed(author)]}); | ||||
|                         return send({ | ||||
|                             content: "You don't have enough Mons for that.", | ||||
|                             embeds: [getMoneyEmbed(author, true)] | ||||
|                         }); | ||||
|                     else if (receiver.money < amount) | ||||
|                         return send({ | ||||
|                             content: "They don't have enough Mons for that.", | ||||
|                             embeds: [getMoneyEmbed(target)] | ||||
|                             embeds: [getMoneyEmbed(target, true)] | ||||
|                         }); | ||||
| 
 | ||||
|                     return send("How long until the bet ends?"); | ||||
|  | @ -72,12 +75,12 @@ export const BetCommand = new NamedCommand({ | |||
|                         else if (sender.money < amount) | ||||
|                             return send({ | ||||
|                                 content: "You don't have enough Mons for that.", | ||||
|                                 embeds: [getMoneyEmbed(author)] | ||||
|                                 embeds: [getMoneyEmbed(author, true)] | ||||
|                             }); | ||||
|                         else if (receiver.money < amount) | ||||
|                             return send({ | ||||
|                                 content: "They don't have enough Mons for that.", | ||||
|                                 embeds: [getMoneyEmbed(target)] | ||||
|                                 embeds: [getMoneyEmbed(target, true)] | ||||
|                             }); | ||||
| 
 | ||||
|                         // handle invalid duration
 | ||||
|  |  | |||
|  | @ -1,4 +1,3 @@ | |||
| import {TextChannel} from "discord.js"; | ||||
| import {Command, getUserByNickname, NamedCommand, confirm, RestCommand} from "onion-lasers"; | ||||
| import {pluralise} from "../../../lib"; | ||||
| import {Storage} from "../../../structures"; | ||||
|  | @ -139,7 +138,10 @@ export const PayCommand = new NamedCommand({ | |||
| 
 | ||||
|                     if (amount <= 0) return send("You must send at least one Mon!"); | ||||
|                     else if (sender.money < amount) | ||||
|                         return send({content: "You don't have enough Mons for that.", embeds: [getMoneyEmbed(author)]}); | ||||
|                         return send({ | ||||
|                             content: "You don't have enough Mons for that.", | ||||
|                             embeds: [getMoneyEmbed(author, true)] | ||||
|                         }); | ||||
|                     else if (target.id === author.id) return send("You can't send Mons to yourself!"); | ||||
|                     else if (target.bot && !IS_DEV_MODE) return send("You can't send Mons to a bot!"); | ||||
| 
 | ||||
|  | @ -166,7 +168,10 @@ export const PayCommand = new NamedCommand({ | |||
| 
 | ||||
|                 if (amount <= 0) return send("You must send at least one Mon!"); | ||||
|                 else if (sender.money < amount) | ||||
|                     return send({content: "You don't have enough Mons to do that!", embeds: [getMoneyEmbed(author)]}); | ||||
|                     return send({ | ||||
|                         content: "You don't have enough Mons to do that!", | ||||
|                         embeds: [getMoneyEmbed(author, true)] | ||||
|                     }); | ||||
|                 else if (!guild) | ||||
|                     return send("You have to use this in a server if you want to send Mons with a username!"); | ||||
| 
 | ||||
|  |  | |||
|  | @ -21,7 +21,7 @@ export const MondayCommand = new NamedCommand({ | |||
|                     user.money++; | ||||
|                     user.lastMonday = now.getTime(); | ||||
|                     Storage.save(); | ||||
|                     send({content: "It is **Mon**day, my dudes.", embeds: [getMoneyEmbed(author)]}); | ||||
|                     send({content: "It is **Mon**day, my dudes.", embeds: [getMoneyEmbed(author, true)]}); | ||||
|                 } else send("You've already claimed your **Mon**day reward for this week."); | ||||
|             } else { | ||||
|                 const weekdayName = WEEKDAY[weekday]; | ||||
|  | @ -47,7 +47,7 @@ export const AwardCommand = new NamedCommand({ | |||
|                 const user = Storage.getUser(target.id); | ||||
|                 user.money++; | ||||
|                 Storage.save(); | ||||
|                 send({content: `1 Mon given to ${target.username}.`, embeds: [getMoneyEmbed(target)]}); | ||||
|                 send({content: `1 Mon given to ${target.username}.`, embeds: [getMoneyEmbed(target, true)]}); | ||||
|             } else { | ||||
|                 send("This command is restricted to the bean."); | ||||
|             } | ||||
|  | @ -64,7 +64,7 @@ export const AwardCommand = new NamedCommand({ | |||
|                         Storage.save(); | ||||
|                         send({ | ||||
|                             content: `${pluralise(amount, "Mon", "s")} given to ${target.username}.`, | ||||
|                             embeds: [getMoneyEmbed(target)] | ||||
|                             embeds: [getMoneyEmbed(target, true)] | ||||
|                         }); | ||||
|                     } else { | ||||
|                         send("You need to enter a number greater than 0."); | ||||
|  |  | |||
|  | @ -4,10 +4,28 @@ import {User, Guild, TextChannel, DMChannel, NewsChannel, Channel, TextBasedChan | |||
| 
 | ||||
| export const ECO_EMBED_COLOR = 0xf1c40f; | ||||
| 
 | ||||
| export function getMoneyEmbed(user: User): object { | ||||
| export function getMoneyEmbed(user: User, inline: boolean = false): object { | ||||
|     const profile = Storage.getUser(user.id); | ||||
|     console.log(profile); | ||||
| 
 | ||||
|     if (inline) { | ||||
|         return { | ||||
|             color: ECO_EMBED_COLOR, | ||||
|             author: { | ||||
|                 name: user.username, | ||||
|                 icon_url: user.displayAvatarURL({ | ||||
|                     format: "png", | ||||
|                     dynamic: true | ||||
|                 }) | ||||
|             }, | ||||
|             fields: [ | ||||
|                 { | ||||
|                     name: "Balance", | ||||
|                     value: pluralise(profile.money, "Mon", "s") | ||||
|                 } | ||||
|             ] | ||||
|         }; | ||||
|     } else { | ||||
|         return { | ||||
|             embeds: [ | ||||
|                 { | ||||
|  | @ -28,11 +46,13 @@ export function getMoneyEmbed(user: User): object { | |||
|                 } | ||||
|             ] | ||||
|         }; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| export function getSendEmbed(sender: User, receiver: User, amount: number): object { | ||||
|     return { | ||||
|         embed: { | ||||
|         embeds: [ | ||||
|             { | ||||
|                 color: ECO_EMBED_COLOR, | ||||
|                 author: { | ||||
|                     name: sender.username, | ||||
|  | @ -42,7 +62,11 @@ export function getSendEmbed(sender: User, receiver: User, amount: number): obje | |||
|                     }) | ||||
|                 }, | ||||
|                 title: "Transaction", | ||||
|             description: `${sender.toString()} has sent ${pluralise(amount, "Mon", "s")} to ${receiver.toString()}!`, | ||||
|                 description: `${sender.toString()} has sent ${pluralise( | ||||
|                     amount, | ||||
|                     "Mon", | ||||
|                     "s" | ||||
|                 )} to ${receiver.toString()}!`,
 | ||||
|                 fields: [ | ||||
|                     { | ||||
|                         name: `Sender: ${sender.tag}`, | ||||
|  | @ -61,6 +85,7 @@ export function getSendEmbed(sender: User, receiver: User, amount: number): obje | |||
|                     }) | ||||
|                 } | ||||
|             } | ||||
|         ] | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue