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
 |                     // handle invalid amount
 | ||||||
|                     if (amount <= 0) return send("You must bet at least one Mon!"); |                     if (amount <= 0) return send("You must bet at least one Mon!"); | ||||||
|                     else if (sender.money < amount) |                     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) |                     else if (receiver.money < amount) | ||||||
|                         return send({ |                         return send({ | ||||||
|                             content: "They don't have enough Mons for that.", |                             content: "They don't have enough Mons for that.", | ||||||
|                             embeds: [getMoneyEmbed(target)] |                             embeds: [getMoneyEmbed(target, true)] | ||||||
|                         }); |                         }); | ||||||
| 
 | 
 | ||||||
|                     return send("How long until the bet ends?"); |                     return send("How long until the bet ends?"); | ||||||
|  | @ -72,12 +75,12 @@ export const BetCommand = new NamedCommand({ | ||||||
|                         else if (sender.money < amount) |                         else if (sender.money < amount) | ||||||
|                             return send({ |                             return send({ | ||||||
|                                 content: "You don't have enough Mons for that.", |                                 content: "You don't have enough Mons for that.", | ||||||
|                                 embeds: [getMoneyEmbed(author)] |                                 embeds: [getMoneyEmbed(author, true)] | ||||||
|                             }); |                             }); | ||||||
|                         else if (receiver.money < amount) |                         else if (receiver.money < amount) | ||||||
|                             return send({ |                             return send({ | ||||||
|                                 content: "They don't have enough Mons for that.", |                                 content: "They don't have enough Mons for that.", | ||||||
|                                 embeds: [getMoneyEmbed(target)] |                                 embeds: [getMoneyEmbed(target, true)] | ||||||
|                             }); |                             }); | ||||||
| 
 | 
 | ||||||
|                         // handle invalid duration
 |                         // handle invalid duration
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| import {TextChannel} from "discord.js"; |  | ||||||
| import {Command, getUserByNickname, NamedCommand, confirm, RestCommand} from "onion-lasers"; | import {Command, getUserByNickname, NamedCommand, confirm, RestCommand} from "onion-lasers"; | ||||||
| import {pluralise} from "../../../lib"; | import {pluralise} from "../../../lib"; | ||||||
| import {Storage} from "../../../structures"; | 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!"); |                     if (amount <= 0) return send("You must send at least one Mon!"); | ||||||
|                     else if (sender.money < amount) |                     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.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!"); |                     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!"); |                 if (amount <= 0) return send("You must send at least one Mon!"); | ||||||
|                 else if (sender.money < amount) |                 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) |                 else if (!guild) | ||||||
|                     return send("You have to use this in a server if you want to send Mons with a username!"); |                     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.money++; | ||||||
|                     user.lastMonday = now.getTime(); |                     user.lastMonday = now.getTime(); | ||||||
|                     Storage.save(); |                     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 send("You've already claimed your **Mon**day reward for this week."); | ||||||
|             } else { |             } else { | ||||||
|                 const weekdayName = WEEKDAY[weekday]; |                 const weekdayName = WEEKDAY[weekday]; | ||||||
|  | @ -47,7 +47,7 @@ export const AwardCommand = new NamedCommand({ | ||||||
|                 const user = Storage.getUser(target.id); |                 const user = Storage.getUser(target.id); | ||||||
|                 user.money++; |                 user.money++; | ||||||
|                 Storage.save(); |                 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 { |             } else { | ||||||
|                 send("This command is restricted to the bean."); |                 send("This command is restricted to the bean."); | ||||||
|             } |             } | ||||||
|  | @ -64,7 +64,7 @@ export const AwardCommand = new NamedCommand({ | ||||||
|                         Storage.save(); |                         Storage.save(); | ||||||
|                         send({ |                         send({ | ||||||
|                             content: `${pluralise(amount, "Mon", "s")} given to ${target.username}.`, |                             content: `${pluralise(amount, "Mon", "s")} given to ${target.username}.`, | ||||||
|                             embeds: [getMoneyEmbed(target)] |                             embeds: [getMoneyEmbed(target, true)] | ||||||
|                         }); |                         }); | ||||||
|                     } else { |                     } else { | ||||||
|                         send("You need to enter a number greater than 0."); |                         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 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); |     const profile = Storage.getUser(user.id); | ||||||
|     console.log(profile); |     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 { |         return { | ||||||
|             embeds: [ |             embeds: [ | ||||||
|                 { |                 { | ||||||
|  | @ -29,10 +47,12 @@ export function getMoneyEmbed(user: User): object { | ||||||
|             ] |             ] | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| export function getSendEmbed(sender: User, receiver: User, amount: number): object { | export function getSendEmbed(sender: User, receiver: User, amount: number): object { | ||||||
|     return { |     return { | ||||||
|         embed: { |         embeds: [ | ||||||
|  |             { | ||||||
|                 color: ECO_EMBED_COLOR, |                 color: ECO_EMBED_COLOR, | ||||||
|                 author: { |                 author: { | ||||||
|                     name: sender.username, |                     name: sender.username, | ||||||
|  | @ -42,7 +62,11 @@ export function getSendEmbed(sender: User, receiver: User, amount: number): obje | ||||||
|                     }) |                     }) | ||||||
|                 }, |                 }, | ||||||
|                 title: "Transaction", |                 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: [ |                 fields: [ | ||||||
|                     { |                     { | ||||||
|                         name: `Sender: ${sender.tag}`, |                         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