Add the economy boat cog
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
This commit is contained in:
parent
477974d53c
commit
7da3f0ab66
10 changed files with 1968 additions and 0 deletions
11
unbelievaboat/__init__.py
Normal file
11
unbelievaboat/__init__.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from .unbelievaboat import Unbelievaboat
|
||||
|
||||
__red_end_user_data_statement__ = (
|
||||
"This cog stores data attached to a users ID for intent of showing a balance.\n"
|
||||
"It does not store user data.\n"
|
||||
"This cog supports data removal requests."
|
||||
)
|
||||
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Unbelievaboat(bot))
|
15
unbelievaboat/abc.py
Normal file
15
unbelievaboat/abc.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from abc import ABC
|
||||
|
||||
from redbot.core import Config
|
||||
from redbot.core.bot import Red
|
||||
|
||||
|
||||
class MixinMeta(ABC):
|
||||
"""Base class for well behaved type hint detection with composite class.
|
||||
|
||||
Basically, to keep developers sane when not all attributes are defined in each mixin.
|
||||
"""
|
||||
|
||||
def __init__(self, *_args):
|
||||
self.config: Config
|
||||
self.bot: Red
|
46
unbelievaboat/checks.py
Normal file
46
unbelievaboat/checks.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
import discord
|
||||
from redbot.core import bank, commands
|
||||
|
||||
|
||||
def check_global_setting_admin():
|
||||
async def predicate(ctx):
|
||||
author = ctx.author
|
||||
if await bank.is_global():
|
||||
return await ctx.bot.is_owner(author)
|
||||
|
||||
if not isinstance(ctx.channel, discord.abc.GuildChannel):
|
||||
return False
|
||||
if await ctx.bot.is_owner(author):
|
||||
return True
|
||||
if author == ctx.guild.owner:
|
||||
return True
|
||||
if ctx.channel.permissions_for(author).manage_guild:
|
||||
return True
|
||||
admin_roles = set(await ctx.bot.get_admin_role_ids(ctx.guild.id))
|
||||
for role in author.roles:
|
||||
if role.id in admin_roles:
|
||||
return True
|
||||
|
||||
return commands.check(predicate)
|
||||
|
||||
|
||||
def wallet_disabled_check():
|
||||
async def predicate(ctx):
|
||||
if await bank.is_global():
|
||||
return await ctx.bot.get_cog("Unbelievaboat").config.disable_wallet()
|
||||
if ctx.guild is None:
|
||||
return False
|
||||
return await ctx.bot.get_cog("Unbelievaboat").config.guild(ctx.guild).disable_wallet()
|
||||
|
||||
return commands.check(predicate)
|
||||
|
||||
|
||||
def roulette_disabled_check():
|
||||
async def predicate(ctx):
|
||||
if await bank.is_global():
|
||||
return await ctx.bot.get_cog("Unbelievaboat").config.roulette_toggle()
|
||||
if ctx.guild is None:
|
||||
return False
|
||||
return await ctx.bot.get_cog("Unbelievaboat").config.guild(ctx.guild).roulette_toggle()
|
||||
|
||||
return commands.check(predicate)
|
534
unbelievaboat/defaultreplies.py
Normal file
534
unbelievaboat/defaultreplies.py
Normal file
|
@ -0,0 +1,534 @@
|
|||
work = [
|
||||
"You work in the mines for {amount}.",
|
||||
"You cut down a tree for {amount}.",
|
||||
"You drive women to the store for {amount}.",
|
||||
"You work as a software developer and earn {amount}",
|
||||
"You work as a behaviour consultant and earn {amount}",
|
||||
"You are paid {amount} to clean up hair off the ground at your local hairdressers.",
|
||||
"You work as a Red-DiscordBot developer and earn {amount}.",
|
||||
"You work for a private military company, earning {amount}",
|
||||
"You work as a courier for the day. You are paid {amount}",
|
||||
"You did a 30 minute workout. While jogging you found {amount} on the floor.",
|
||||
"You shine people's shoes in class and they give you {amount}.",
|
||||
"You shine people's shoes in the mall and earn {amount}.",
|
||||
"You worked at the office overtime for {amount}.",
|
||||
"You worked at the office and earned {amount}.",
|
||||
"{amount} falls out of the sky and hits you on the head.",
|
||||
"You help a newcomer set up a camp and they pay you {amount}",
|
||||
"You work at a summer camp and earn {amount}.",
|
||||
"You work in a local bookmakers and earn {amount}.",
|
||||
"You work in your local shop and get paid {amount}.",
|
||||
"You earn {amount} from a football bet.",
|
||||
"You got featured and won {amount}",
|
||||
"You work as a vibration consultant and earn {amount}",
|
||||
"You worked as a Bride Kidnapping Expert, for that you were paid {amount}",
|
||||
"You become a game developer and raised {amount} for charity.",
|
||||
"You toasted some bread. A step in the right direction. You earned {amount}",
|
||||
"You come home full of sweat after a hard day of boxing, the sponsors give you {amount}",
|
||||
"You put on a spring lock suit and entertain the customers. You receive {amount}",
|
||||
"You worked as a diaper changer, you were paid {amount}",
|
||||
"You eat bananas for a living and get {amount}",
|
||||
"You didn't go to work, but you got your paycheck of {amount} anyway.",
|
||||
"You work as a bread scientist and earn {amount}",
|
||||
"Nothing says a good day like being a programmer for C#. You earn {amount} despite you keep Googling all your problems.",
|
||||
"You work as a snake milker and earn {amount}",
|
||||
"You take your cat for a walk and gain {amount}",
|
||||
"You host a fine wine tasting event and get {amount}",
|
||||
"You help Preda collect porn for Martine and he pays you {amount}",
|
||||
"You work as an extra for Avengers 4. You didn’t feel so good, but you got {amount}",
|
||||
"You cleaned 200 toilets in the prison. The lazy janitor thanked you and gave you {amount}",
|
||||
"You sweep the floor and get paid {amount}",
|
||||
"You put your nose to the grindstone and earned {amount}",
|
||||
"You worked and gained {amount}",
|
||||
"You work as a comedian and earn {amount}",
|
||||
"You work as an experienced boner and earn {amount}",
|
||||
"Great job! You work as a professional professional and got {amount}",
|
||||
"You've worked on a farm cultivating wheat from dawn to dusk. The land lord pays you {amount} for your struggles.",
|
||||
"You work as a window cleaner for the Gherkin in London and earn {amount}",
|
||||
"You catch fish for a few hours and give them to your boss. They pay you {amount} for a good job.",
|
||||
"You enter a website contest and beat Club Penguin, Twitter, and Facebook. Receive {amount}",
|
||||
"You work 10 minutes at a local Pizza Hut. You earned {amount}",
|
||||
"You take part in a Civil War battle and earn {amount} for your team winning!",
|
||||
"Work at the icecream shop of your childhood dreams and earn {amount}",
|
||||
"You work extra hard at the office today, but instead of gaining a promotion you earn a donut and {amount} Good job.",
|
||||
"You work as an elephant dresser and earn {amount}",
|
||||
"You sold 3 copies of the Shrek movie and earned {amount}",
|
||||
"You work as a director of sandbags and earn {amount}",
|
||||
"You worked for {amount}",
|
||||
"You press some buttons on a keyboard, gaining {amount}",
|
||||
"You work as a gender equality consultant and earn {amount}",
|
||||
"You did absolutely nothing and still managed to get paid {amount}",
|
||||
"You start up a very small company that made near no money before you sold it for {amount}",
|
||||
"You create and launch a game on Roblox, it becomes a hit! You get money from people buying early access, in game passes and currency in game, you convert the Robux you earn into server money you got {amount}",
|
||||
"You work as a professional sleeper and earn {amount}",
|
||||
"You work as a janitor and earn {amount}",
|
||||
"You try to find out how many licks it takes to get to the center of a Tootsie Pop. Turns out it's 3 and a crunch. The research team pays you {amount}",
|
||||
"You dig around in your yard and gain {amount}",
|
||||
"You work as a flatulence smell reduction underwear maker and earn {amount}",
|
||||
"You make a living selling weed, for {amount} a day",
|
||||
"You work as a police officer and earn {amount}",
|
||||
"You work at Mario's Plumbing Service for {amount}",
|
||||
"You dig around in your yard and gain {amount}",
|
||||
"You drive women to the store for {amount}",
|
||||
"You begin to code a game you have been thinking about for a while, and your friends give you {amount} to help fund the project!",
|
||||
"You work as a parkour specialist and earn {amount}",
|
||||
"You work as a ear cleaner and earn {amount}",
|
||||
"You work as a flatulence smell reduction underwear maker and earn {amount}",
|
||||
"You worked for the Police and earned {amount}",
|
||||
"You work at the dump all day. Then you found {amount} from a thrown out wallet.",
|
||||
"You work as a beaver expert and earn {amount}",
|
||||
"You worked hard at your dish cleaning job but failed. Then you tried fish cleaning! You earned {amount}",
|
||||
"You drive women to the store for {amount}",
|
||||
"After scrubbing each toilet twice with a toothbrush, your coworker pays you {amount} as it was originally their job",
|
||||
"You battled and gained {amount}",
|
||||
"You actually went to work today like a normal person. William throws {amount} at you, ouch!",
|
||||
"You clean off the counters and get paid {amount}",
|
||||
"You posted something to the subreddit! You've earned {amount}",
|
||||
"You work as a PlayStation brand ambassador and earn {amount}",
|
||||
"You made a great pun ! Take this : {amount}",
|
||||
"You enter a fidget spinner spinning contest and out-spin the other fidget spinner spinners. You make {amount}",
|
||||
"You sell your crab for {amount} you monster",
|
||||
"Why can't you get a real job and make real money? Because digging through the dirt is more fun. You gain {amount}",
|
||||
"You clean off the counters and get paid {amount}",
|
||||
"You beat sonic wave infinity and won {amount}",
|
||||
"You are kidnapped and taken to an underground coliseum where you fought off monsters with people you’ve never met before. You earn {amount} albeit reluctantly.",
|
||||
"You work as a police officer and earn {amount}",
|
||||
"You work as a serial murderer... and earn {amount}",
|
||||
"You helped the druids to make their potions, they give you {amount}",
|
||||
"You overslept and miss work, but a buddy clocked you in so you got paid {amount}",
|
||||
"You work as a human statue and earn {amount}",
|
||||
"You work as a human scarecrow (yes.. you're that ugly) and earn {amount}",
|
||||
"You work for Microsoft's marketing department. You get a free XBOX One S and {amount}",
|
||||
"You work as the head of elephants and earn {amount}",
|
||||
"You work at Disneyland as a panda in a costume and earn {amount}",
|
||||
"You help clean up a local bar, the bar owner pays you {amount} for your work.",
|
||||
"You milk cows for a few hours because the farmer is sick! You are paid {amount} for doing their job.",
|
||||
"You scavenge a local garbage dump and find {amount} worth of scrap.",
|
||||
"You and your mariachi band play music at a wedding. {amount}",
|
||||
"You spent an 8 hour shift walking around in 10 inch heels and a nice dress handing out flyers to rude customers. Your feet are killing you, and you can't wait to get that dress off. At least you got paid {amount} for it.",
|
||||
"You work as an iceberg mover and earn {amount}",
|
||||
"You baked some nice cookies for all, here is {amount}",
|
||||
"You help clean up the local theater. You find {amount} strewn about between the seats!",
|
||||
"You got cloned for science. You earned {amount}",
|
||||
"You work as a voice actor for Spongebob and managed to gain {amount}",
|
||||
"You take your dog for a walk and gain {amount}",
|
||||
"Taxes collected! You have gained {amount}",
|
||||
"You work as a sandwich artist and earn {amount}",
|
||||
"You work as a bush pruner for Donald Trump and earn {amount}",
|
||||
"You did some social work for a good cause ! You received {amount} for your contributions !",
|
||||
"You work as a bounty hunter and earn {amount}",
|
||||
"You drive women to the store for {amount}",
|
||||
"You dabbed so hard that even your mother is proud! You make {amount} off of donations.",
|
||||
"You work as a helpdesk technician and earn {amount}",
|
||||
"You work as a plus sized model and earn {amount}",
|
||||
"You worked as a businessman and earned {amount}",
|
||||
"You defended an old lady from robbers. You got a smooch on the cheek and earned {amount}",
|
||||
"You work as a voice actor for Spongebob and managed to gain {amount}",
|
||||
"You work as a wine taster and earn {amount}",
|
||||
"You get fired for sleeping on the job, but found {amount} on the way back home!",
|
||||
"Just take the {amount} and go...",
|
||||
"You got out of bed. Have {amount}",
|
||||
"You complete a daily quest that takes you about 3 hours and you gain {amount} Even though you lost half of your ammo, broke all of your guns, and your spirit is all but crushed",
|
||||
"You work as a personal shopper and earn {amount}",
|
||||
"You get a commission request, the payment is {amount}",
|
||||
"You found {amount} on the floor.",
|
||||
"You work all day at the factory {amount}",
|
||||
"After a long day of tolerating your annoying co-workers, your boss pays you extra and you earn {amount}",
|
||||
"Your job as a fart collector is very interesting and earns you {amount} .",
|
||||
"You see someone struggling to lift a box into their car, you rush over to help them before they hurt themselves. After helping them, they graciously give you {amount}",
|
||||
"You work as a streamer and gain {amount} from donations",
|
||||
"You work as a smarties expert and earn {amount}",
|
||||
"You work from 9 to 5 in a law firm as an accountant, going through profits and expenditure accounts. At the end of the day, the papers earns you {amount}",
|
||||
"You work as an elementary school teacher and earn {amount}",
|
||||
"You paint a lovely watercolor Moon and sell it at a local art fair for {amount}",
|
||||
"You work as a sandcastle builder and earn {amount}",
|
||||
"You get a commission request, the payment is {amount}",
|
||||
"You work as a body pillow factory salesman on the internet for real weebs, the weebs gave you {amount}",
|
||||
"You gave yourself {amount} that you didn't even have! What is this wizardry..",
|
||||
"You helped out your boss and worked hard, earning {amount}",
|
||||
"You get a letter saying you've won a cash prize of {amount} with an address to collect your winnings at. The weird thing is you don't recall entering any contest...",
|
||||
"You work as a fortune cookie writer and earn {amount}",
|
||||
"You worked hard at your dish cleaning job but failed. Then you tried fish cleaning! You earned {amount}",
|
||||
"You clean off the chairs and get paid {amount}",
|
||||
"You scavenge a local garbage dump and find {amount} worth of scrap.",
|
||||
"You work as an experienced bra fitter and earn {amount}",
|
||||
"You baked some nice cookies for all, here is {amount}",
|
||||
"You work hard all day and your boss pays you {amount} after the pizzeria closes down.",
|
||||
"You repair the arcade machines and receive {amount}",
|
||||
"You work as a body double for Shakira. And your hips really don’t lie. You earn {amount}",
|
||||
"You work as an iceberg mover and earn {amount}",
|
||||
"You clean poop off the stalls at walmart and get {amount}",
|
||||
"You worked hard moving your dad's lawn and he gave you {amount}",
|
||||
"You found {amount} on the floor.",
|
||||
"You work as a penguinologist and earn {amount}",
|
||||
"You pour coffee into a cup and successfully deliver it to a customer for {amount}",
|
||||
"You work as a human scarecrow (yes.. you're that ugly) and earn {amount}",
|
||||
"You suggest something good and get rewarded {amount}",
|
||||
"You work as a taxi driver and earn {amount}",
|
||||
"You got more than 1000 subscribers on YouTube, your last video made you really famous, and then come the YouTube money : {amount}",
|
||||
"You actually went to work today like a normal person. William throws {amount} at you, ouch!",
|
||||
"You work as a cookie cutter and earn {amount}",
|
||||
"You work at a lamp store and earn {amount}",
|
||||
"You work as a pumpkin painter and are surprised to find {amount} stashed inside one of them.",
|
||||
"You work as a highschool student with no life. Have {amount} because we pity you.",
|
||||
"You stack cups at 7-11 for 8 hours a day, racking up a measly {amount}",
|
||||
"You work as a sandwich artist and earn {amount}",
|
||||
"You develop games and earn {amount}",
|
||||
"You work as a streamer and gain {amount} from donations",
|
||||
"You work as a bed warmer and earn {amount}",
|
||||
"You work as a ear cleaner and earn {amount}",
|
||||
"You did some odd jobs in the city and earned {amount} Good job !",
|
||||
"You receive a check of {amount} after having done some clever business with a friend in the markets.",
|
||||
"You work as a part time game programmer. You rake in {amount}",
|
||||
"You worked as a substitute teacher in a school and earned {amount} The students loved you !",
|
||||
"You work as a dog surfing instructor and earn {amount}",
|
||||
"You work as a toy manufacturer and sell toys to kids for {amount}",
|
||||
"You work at a chinese camera repair shop and get berated all day and make {amount}",
|
||||
"You drove the school bus today and were only 5 minutes late, but you still got {amount} for your efforts!",
|
||||
"You got hired as a stripper! You work that pole and make {amount}",
|
||||
"You work as a toy manufacturer and sell toys to kids for {amount}",
|
||||
"You work as a children's toy tester and earn {amount}",
|
||||
"You work as a body pillow factory salesman on the internet for real weebs, the weebs gave you {amount}",
|
||||
"You carried a bunch of schoolbags around to different classes for a day, and received {amount} from your peers.",
|
||||
"You work as a professional Minecraft hacker. You manage to rake in {amount}",
|
||||
"You work as an eel ecologist and earn {amount}",
|
||||
"You work as a professional snuggler and earn {amount}",
|
||||
"You fixed a broken down T-60 Tank in Afghanistan. The crew paid you {amount} when you got back home",
|
||||
"You work as a cross dresser model and earn {amount}",
|
||||
"You had a fruitful day at the office today and earned {amount}",
|
||||
"You work as a pumpkin picker {amount}",
|
||||
"You work at Grandma's restaurant as a cook and earn {amount}",
|
||||
"You work as crisis actor and earn {amount}",
|
||||
"You work in Subway (other sandwich shops are available) and earn {amount}",
|
||||
"You help set up MemeHub, and earned {amount}",
|
||||
"You work as a PlayStation brand ambassador and earn {amount}",
|
||||
"You got out of bed. Have {amount}",
|
||||
"You work as a professional wine taster and earn {amount}",
|
||||
"You sell Girl Scout Cookies and earn {amount}",
|
||||
"You work as a professional cock fighter and earn {amount}",
|
||||
"You work as a professional cleaner. After hiding the body, you're handed {amount}",
|
||||
"You serve the customers and receive {amount}",
|
||||
"You work as a smarties expert and earn {amount}",
|
||||
"You work as a sewer inspector and earn {amount}",
|
||||
"Instead of going to work, you decided to look for money on the ground. Fortunately enough, you found {amount}",
|
||||
"You have a successful YouTube channel and make {amount} for that sweet, sweet AD revenue",
|
||||
"You work in Greggs and earn {amount}",
|
||||
"You receive a check of {amount} after having done some clever business with a friend in the markets.",
|
||||
"Your work at a market selling apples with a shop clerk for a day. They pay you {amount} for helping them out.",
|
||||
"While you were searching for Pokémon in the tall grass, you found {amount}",
|
||||
"Just take the {amount} and go...",
|
||||
"You and your mariachi band play music at a wedding. {amount}",
|
||||
"You are hired by the Mojave Express to deliver a package to The King in Freeside. You are paid {amount}",
|
||||
"You win a spicy chili eating contest. The prize is {amount}",
|
||||
"You dabbed so hard that even your mother is proud! You make {amount} off of donations.",
|
||||
"Your level got featured epic and you won {amount}",
|
||||
"You work as a water slide tester and earn {amount}",
|
||||
"You find {amount} randomly lying in the gutter",
|
||||
"You do some work around the house for {amount}",
|
||||
"The demand for mobile games has increased so you create a new game full of microtransactions. You earn a total of {amount} off your new game.",
|
||||
"You beat sonic wave infinity and won {amount}",
|
||||
"You work at a lamp store and earn {amount}",
|
||||
"While you were searching for Pokémon in the tall grass, you found {amount}",
|
||||
"You help clean up the local theater. You find {amount} strewn about between the seats!",
|
||||
"You work as a beefeater and earn {amount}",
|
||||
"You work as a breath odor evaluator and earn {amount}",
|
||||
"You battled and gained {amount}",
|
||||
"Mr. Beast came to give you random amounts of money, you received {amount}",
|
||||
"You work as an IMAX screen cleaner and earn {amount}",
|
||||
"You worked overtime for {amount}",
|
||||
"You clean poop off the stalls at Walmart and get {amount}",
|
||||
"You work as a space lawyer and earn {amount}",
|
||||
"You enter a fidget spinner spinning contest and out-spin the other fidget spinner spinners. You make {amount}",
|
||||
"You work as a pumpkin painter and are surprised to find {amount} stashed inside one of them.",
|
||||
"You take an hour to patch a broken water pipe in the yard and earn {amount}",
|
||||
"You work as a paper towel sniffer and earn {amount}",
|
||||
"You helped out your boss and worked hard, earning {amount}",
|
||||
"You help clean up a local bar, the bar owner pays you {amount} for your work.",
|
||||
"You clean off the animatronics and get paid {amount}",
|
||||
"You worked your very best at a printing press which was hiring and earned your well deserved {amount} !",
|
||||
"You work all day at the factory {amount}",
|
||||
"Somebody once told me the world was gonna roll me, I ain't the sharpest tool in the sh- oh, uh- you did something good and got {amount} I think...",
|
||||
"You work as crisis actor and earn {amount}",
|
||||
"You worked for Cubic.Games as their program team member. A measly {amount} was earn.",
|
||||
"You work as a professional cuddler and earn {amount}",
|
||||
"You sold knock-off Squishees and cashed out with {amount}",
|
||||
"You work as an engineer and earn {amount}",
|
||||
"You drove new recruits to the base and you got paid {amount} for doing it",
|
||||
"You work as a bride kidnapper and earn {amount}",
|
||||
"You worked your very best at a printing press which was hiring and earned your well deserved {amount} !",
|
||||
"You carefully clean the spring lock suits and receive {amount}",
|
||||
"You work as a professional cat-petter and earn {amount}",
|
||||
"You work as a fortune cookie writer and earn {amount}",
|
||||
"You hastily wipe down the Café counters. Your boss pays you {amount}",
|
||||
"You got cloned for science. You earned {amount}",
|
||||
"You clean off the tables and get paid {amount}",
|
||||
"You take your dog for a walk and gain {amount}",
|
||||
"You work as the namer of clouds and earn {amount}",
|
||||
"You take your dog for a walk and gain {amount}",
|
||||
"You run a relatively popular Tumblr blog and make {amount} from ad revenue.",
|
||||
"You work as a pumpkin picker {amount}",
|
||||
]
|
||||
crimes = [
|
||||
"You rob a bank for {amount}.",
|
||||
"You steal a car and sell it for {amount}.",
|
||||
"You steal and car and scrap it for {amount}.",
|
||||
"You rob a liquor store for {amount}.",
|
||||
"You rob an old woman for {amount}.",
|
||||
"You steal a kids bike from the playground for {amount}.",
|
||||
"You and your posy rob a bank for {amount}.",
|
||||
"You see a man digging up a grave. He pays you {amount} to help him.",
|
||||
"You sell drugs on the corner block for {amount}.",
|
||||
"You pickpocket a noble and find {amount} in their wallet.",
|
||||
"You launder {amount} through a local hairdressers.",
|
||||
"You robbed the Grinch and happen to find something in his collection! You sell it for {amount}",
|
||||
"You scam an old couple out of {amount}",
|
||||
"You earn {amount} from an insurance fraud scheme",
|
||||
"You gain {amount} after breaking into a house.",
|
||||
"You rob your friends wallet and find {amount}",
|
||||
"You find a trading vulnerability in a game and duplicate inventory for which you sell and earn {amount}",
|
||||
"You steal your grandma's purse, and find {amount} and some butterscotch candy.",
|
||||
"You crack open a safe and shovel {amount} into your pockets. These old people never learn.",
|
||||
"You see a man burying a dead body in the park. He pays you {amount} to help him out.",
|
||||
"You stole a package from your neighbor and sold it on the deep web for {amount}",
|
||||
"You sell your kidney on the black market for {amount}",
|
||||
"You steal a painting of a moustached man and sell it for {amount}",
|
||||
"You post nudes on the internet for {amount}",
|
||||
"You manage to persuade a Lord into thinking that you're a banker. He gives you his {amount} for safe keeping .",
|
||||
"You tried to help someone with a bot, but they were greedy and stole {amount} from you!",
|
||||
"You sold drugs for {amount}",
|
||||
"You rob the Goodsprings General Store and come out with {amount}",
|
||||
"You pickpocket a candy seller for {amount}",
|
||||
"Your SoundCloud DJ roommate plays their music at 120 DB until 5am in the morning. In a seething blind rage, you kill them and sell their equipment for {amount}",
|
||||
"You travel back in time to before the Gold Rush began and take all the gold. You travel back to the present and trade it in for {amount}",
|
||||
"Don't tell anybody what you just did. Here is {amount}",
|
||||
"You steal a customer's lucky gold coin which you sell for {amount}",
|
||||
"On Highway 9 you come across a courier heading to New Tulsa. You have a small conversation and figure out they are transporting a shipment of scavenged poker chips. Filled with greed, you put a bullet in their gut and loot the package. When returning to New Tulsa you sneak the chips into the Hard Rock and cash them in for {amount} No one found out...thank God.",
|
||||
"With a few others, you light up a molotov and throw it at a shop. Somehow you find {amount} on the way back.",
|
||||
"You steal an apple from the market and saved {amount}",
|
||||
"You make a profit selling catnip on the streets, and get {amount}",
|
||||
"You went to rob a bank and failed miserably, although you did escape the cops and made it back to your apartment. You found {amount} on the ground in the parking lot.",
|
||||
"You successfully created a pyramid scheme making {amount} in the process.",
|
||||
"You help illegal immigrants cross the border and they paid you {amount}",
|
||||
"You access the point log and clear everything, gaining {amount}",
|
||||
"You walk down the street and find someone beating up an old man...so you decided to join in on the fun and get {amount} from the man's wallet.",
|
||||
"You pickpocket a man/woman. You manage to get {amount}",
|
||||
"You rob a liquor store for {amount}",
|
||||
"You stole a couple rifles and sold it for {amount}",
|
||||
"You sell your first mixtape and earn {amount}",
|
||||
"You start up a detective service for a few days, but when you finally get business you end up robbing your client for {amount}",
|
||||
"You hacked this server and got {amount}",
|
||||
"You dabbed on the haters and got {amount}",
|
||||
"You manage to slip some gemstones into your pockets when the store owner isn't looking, selling them later for {amount}",
|
||||
"You kidnap a citizen and take them hostage for {amount}",
|
||||
"You successful raid a popular server and steal all their members. You get {amount} in Patron donations.",
|
||||
"You download and repost an art tutorial on YouTube that gets a lot of hits, {amount} arrives in the mail the next day.",
|
||||
"You robbed a bank and got {amount}",
|
||||
"You found {amount} under your bus seat. Shhh! Don't tell anyone.",
|
||||
"The Russian government pays you {amount} after you successfully blow up an arms depot.",
|
||||
"You steal the Queen's crown and sell it on the black market for {amount}",
|
||||
"You kidnap a bride and take her hostage for {amount}",
|
||||
"You mug a hobo on the street and manage to get {amount}",
|
||||
"You commit a heist and manage to take {amount}",
|
||||
"You broke into the Warden's office and stole their chair. You managed to sell it for {amount}",
|
||||
"You assassinated an African druglord for {amount}",
|
||||
"You rob a McDonald's and take {amount}",
|
||||
"On the way to work you decided to rob a store and successfully got {amount}",
|
||||
"You travel back in time to before the Gold Rush began and take all the gold. You travel back to the present and trade it in for {amount}",
|
||||
"You steal an orange and pawn it for {amount}",
|
||||
"You rummage through a dumpster illegally and find {amount}",
|
||||
"You steal all the candy from a candy store. After fighting the urge to eat it, you sell it for {amount}",
|
||||
"You storm the local police station and steal all their bribery money worth {amount}",
|
||||
"You raided the enemy tribe and got {amount}",
|
||||
"You steal lamps for {amount}",
|
||||
"You sneak into the White House and manage to get your hands on a small loan of a million dollars. Unfortunately, you lose most of it while escaping, and only take home {amount}",
|
||||
"The local street gang pays you {amount} after helping them beat an innocent citizen",
|
||||
"You steal a car and take it to the junkyard for {amount}",
|
||||
"You receive an unmarked letter in the post. Inside is a check of {amount} which probably means that the 'business' went well.",
|
||||
"You hacked a bank and stole {amount}",
|
||||
"You kill someone and sell their organs for {amount}",
|
||||
"You were hired as an assassin and you succeeded, earning {amount}",
|
||||
"You rob the bank and obtain {amount} Hell yes.",
|
||||
"You see an old woman drop {amount} and take it!",
|
||||
"You steal your neighbor's cat and sell it for {amount}",
|
||||
"You break into a builder's workshop and manage to steal {amount}",
|
||||
"You steal an orange and pawn it for {amount}",
|
||||
"You steal a hobo's money jar for {amount}",
|
||||
"You did a crime and got {amount} from it :/",
|
||||
"You steal a birds egg and sell it on the black market for {amount}",
|
||||
"You rob a squirrel of their nuts and pawn them for {amount}",
|
||||
"You rob from a bank and gained {amount} for escaping without being caught",
|
||||
"You steal a child's piggy bank for {amount}",
|
||||
"You stole a potato and sold it for {amount} on the black market",
|
||||
"You rob the bank and obtain {amount} Hell yes.",
|
||||
"In the guise of darkness you break into a home to steal jewelry worth {amount}",
|
||||
"You sell cellular phones for a whopping {amount}",
|
||||
"You steal an orange and pawn it for {amount}",
|
||||
"You travel back in time to before the Gold Rush began and take all the gold. You travel back to the present and trade it in for {amount}",
|
||||
"You stole a fish and sell it second hand for {amount}",
|
||||
"You stole a mystery box from Walmart, it was full of turtlenecks valued at {amount}",
|
||||
"You're hired as a hitman for {amount}",
|
||||
"You hacked into a terrorist's computer, and managed to earn {amount}",
|
||||
"You milk your videos with clickbait and giveaway-videos, earning {amount}",
|
||||
"The 'Dont Step on the Grass' sign in the park was taunting you, so you pranced all over the grassy fields before picking the pocket of the nearby patrolling traffic officer, you were able to nab {amount} from their pockets.",
|
||||
"You robbed a church and made {amount}",
|
||||
"You break into a home to steal jewelry worth {amount}",
|
||||
"You successfully complete a heist and earn {amount}",
|
||||
"You stole a T-55 Tank and sold it for {amount} on the market",
|
||||
"You stole a fish and sell it second hand for {amount}",
|
||||
"You hack into the government's economy system and manage to steal {amount}",
|
||||
"You steal change from the homeless. You got {amount}",
|
||||
"Those weren't girl scout cookies, but hey you got {amount}",
|
||||
"What me? No, I didn't commit crime. Crime-who? Crime-what? Acquire {amount} for something that definitely wasn't illegal",
|
||||
"You murder that sweet old lady living upstairs, collect her jewelry and sell it for {amount}",
|
||||
"You rob the bank of Eternity for {amount}",
|
||||
"You are paid {amount} to hit yourself.",
|
||||
"A box wobbles & falls from a delivery vehicle, landing right infront of you. Inside you find high-quality cigars. These are worth {amount}",
|
||||
"You pickpocket a passing noble, guess crime does pay after all. You manage to steal {amount}",
|
||||
"You break a window in New York for {amount}",
|
||||
"You walk down the street and find someone beating up an old man...so you decided to join in on the fun and get {amount} from the man's wallet.",
|
||||
"You are paid {amount} to hit yourself.",
|
||||
"You steal candy from some schoolgirls and earn {amount}",
|
||||
"The 'Dont Step on the Grass' sign in the park was taunting you, so you pranced all over the grassy fields before picking the pocket of the nearby partroling traffic officer, you were able to nab {amount} from their pockets.",
|
||||
"You stole a Mi-24 Helicopter and sold it for {amount} on the market",
|
||||
"You hack into the government's economy system and manage to steal {amount}",
|
||||
"You start selling steroids to the players on your team. You manage to make {amount}",
|
||||
"You break into Discord Headquarters, you steal {amount} and escape unnoticed!",
|
||||
"You call a few friends and raid a newspaper shop with machetes. The operation is successful, and from the loot you earn {amount}",
|
||||
"You smuggle pugs across the Mexican border for a cool {amount}",
|
||||
"You pickpocket every single person in the parliament entrance and sneak away with {amount}",
|
||||
"Your hacker friend wires you {amount} Good payroll today gamers.",
|
||||
"You held a bus hostage and got paid {amount}",
|
||||
"You jump the old lady walking down the street. She had {amount} on her.",
|
||||
"You pickpocket someone successfully and steal the money out of their wallet, there was {amount} in it",
|
||||
"You rob a convenience store for {amount}",
|
||||
"You successful raid a popular server and steal all their members. You get {amount} in Patron donations.",
|
||||
"You stole Justin Bieber's wallet and found {amount} in it.",
|
||||
"You successfully take furniture from the Furniture Store and sell it online for {amount}",
|
||||
"You blow up Bungie Headquarters and earn {amount}",
|
||||
"You help an old lady cross the road, {amount} falls out of her purse and you take it!",
|
||||
"You kidnaped a cat and took it hostage for {amount}",
|
||||
"Your hacker friend wires you {amount} Good payroll today gamers.",
|
||||
"A woman gave you {amount} for killing her husband!",
|
||||
"You murdered your old CEO and found {amount} in their jacket!",
|
||||
"You killed a man, and liked it, you got {amount}",
|
||||
"You find {amount} laying on the street",
|
||||
"You sell body parts on the black market {amount} in profit.",
|
||||
"Your friend said that you couldn't steal the Mona Lisa, so to prove them wrong you stole the Mona Lisa and sold it for {amount}",
|
||||
"You break into a hospital and steal all their morphine. You manage to sell all of it on the black market for {amount}",
|
||||
"You rob a gas station of all its fidget spinners. You sell them for {amount} to some 11 year olds.",
|
||||
"You pickpocket somebody and manage to get {amount}",
|
||||
"You sell some cocaine and earn {amount}",
|
||||
"You sold drugs for {amount}",
|
||||
"You manage to hack into a bank's system and steal {amount}",
|
||||
"You break into Discord Headquaters, you steal {amount} and escape unnoticed!",
|
||||
"You successfully take furniture from the Furniture Store and sell it online for {amount}",
|
||||
"You're hired as a hitman for {amount}",
|
||||
"You break into a firework factory and steals all the firecrackers and sell them for {amount}",
|
||||
"You find some farming tools and steal a few when people aren't looking and sell them to a farmer for {amount}",
|
||||
"What me? No, I didn't commit crime. Crime-who? Crime-what? Acquire {amount} for something that definitely wasn't illegal",
|
||||
"A drone drops off your mysterious package and you sell it for {amount}",
|
||||
"You hacked your parents' bank account and made {amount}",
|
||||
"You've been asked to steal the last tiramisu from the kitchen, you got {amount} for a job well done.",
|
||||
"You bombed Antarctica and received {amount}",
|
||||
"You rob a liquor store for {amount}",
|
||||
"You murder the nice lady next door and sell her dead corpse for {amount}",
|
||||
"You break into a builder's workshop and manage to steal {amount}",
|
||||
"You steal {amount} from a loan shark, and move to the other side of the world.",
|
||||
"You work for a mexican cartel and make {amount}",
|
||||
"You set up a fake kickstarter for a game and end up stealing {amount} from unsuspecting investors.",
|
||||
"You steal a police car and sell it on the black market for {amount}",
|
||||
"You steal the Queen's crown and sell it on the black market for {amount}",
|
||||
"You sell cellular phones for a whopping {amount}",
|
||||
"You did a crime and got {amount} from it :/",
|
||||
"You steal {amount} from your boss and don't get caught.",
|
||||
"You hacked Google and stole {amount}",
|
||||
"You successful raid a popular server and steal all their members. You get {amount} in Patron donations.",
|
||||
"You robbed a church and made {amount}",
|
||||
"The Russian government pays you {amount} after you successfully blow up an arms depot.",
|
||||
"You set up a fake kickstarter for a game and end up stealing {amount} from unsuspecting investors.",
|
||||
"You assassinate an actor for {amount}",
|
||||
"You stole a car and sold it for {amount}",
|
||||
"With a few others, you light up a molotov and throw it at a shop. Somehow you find {amount} on the way back.",
|
||||
"You rob another server for {amount}",
|
||||
"You steal a cellphone and sell it on ebay for {amount}",
|
||||
"A drone drops off your mysterious package and you sell it for {amount}",
|
||||
"You entered the Royal Palace and stole a precious diamond. You then sold it for {amount}",
|
||||
"You rob a nearby corner store for {amount}",
|
||||
"You blow up Bungie Headquarters and earn {amount}",
|
||||
"You stole a dog and sold it to the old lady next door for {amount}",
|
||||
"You decided to embrace your inner dark side, and promptly massacre an entire nation, netting you {amount}",
|
||||
"You steal your baby sister's allowance money from her sparkly pink piggy bank. {amount}",
|
||||
"You sell body parts on the black market {amount} in profit.",
|
||||
"You were going to commit a crime but changed your mind and got a job instead. You made {amount} before your boss realized you were a criminal and fired you.",
|
||||
"You steal someone's Halloween candy, and give your friend half of it. They pay you {amount}",
|
||||
"You rob a gas station of all its fidget spinners. You sell them for {amount} to some 11 year olds.",
|
||||
"You walk down the street and find someone beating up an old man...so you decided to join in on the fun and get {amount} from the man's wallet.",
|
||||
"You sell body parts on the black market {amount} in profit.",
|
||||
"You pickpocket someone successfully and steal the money out of their wallet, there was {amount} in it",
|
||||
"You did a crime and for some reason you now have {amount} more",
|
||||
"You hack into the Red-DiscordBot patreon and rob {amount}.",
|
||||
"You steal an apple from the market worth {amount}",
|
||||
"You hacked into a terrorist's computer and managed to earn {amount}",
|
||||
"You rob a wild bank and manage to steal {amount}",
|
||||
"You rob another server for {amount}",
|
||||
"You robbed {amount} from a convenience store.",
|
||||
"You find some farming tools and steal a few when people aren't looking and sell them to a farmer for {amount}",
|
||||
"You rob an orphanage for {amount}",
|
||||
"You stealthily pickpocket a nearby customer with {amount} worth of silver coins.",
|
||||
"You hacked into the bank and received {amount} and an invitation to Anonymous",
|
||||
"You steal your grandma's purse, and find {amount} and some butterscotch candy.",
|
||||
"You work for the Juarez cartel as a brick-presser and earn {amount} They'll probably kill you and your family tomorrow. Just saying.",
|
||||
"You steal a pink McLaren and sell it to Kim Kardashian for {amount}",
|
||||
"You steal a painting of a mustached man and sell it for {amount}",
|
||||
"A drone drops off your mysterious package and you sell it for {amount}",
|
||||
"You robbed a bank and secured {amount}",
|
||||
"You mug someone in a video game for all that they have, too bad it wasn't anything but some worthless bottle caps, netting you {amount}",
|
||||
"Walking along the street, you notice an envelope falling out of the person's bag in front of you. You reach down to get it. After examining the unmarked envelope in your hand, you turn to the person who dropped it, they see you with it and run away at full-speed shoving everyone out of the way. Inside you find a small bag of cocaine. You turn to the nearest junkie & show them the contents, the junkie puts {amount} in your hand silently in exchange for it and walks away.",
|
||||
"You stole from the cookie jar and gave them to your friend for {amount}",
|
||||
"You storm the local police station and steal all their bribery money worth {amount}",
|
||||
"You download and repost an art tutorial on YouTube that gets a lot of hits, {amount} arrives in the mail the next day.",
|
||||
"You decided to embrace your inner dark side, and promptly massacre an entire nation, netting you {amount}",
|
||||
"You work for the Juarez cartel as a brick-presser and earn {amount} They'll probably kill you and your family tomorrow. Just saying.",
|
||||
"You sell some cocaine and earn {amount}",
|
||||
"You need some extra cash for your drug habit. You break into the local dirty video store and rob them of {amount} You also take a few “items” for yourself...",
|
||||
"You steal a painting of a mustached man and sell it for {amount}",
|
||||
"You steal a birds egg and sell it on the black market for {amount}",
|
||||
"You hack into the mainframe, getting {amount} in the process",
|
||||
"You commit a heist and manage to take {amount}",
|
||||
"You rob a convenience store for {amount}",
|
||||
"You assassinate an actor for {amount}",
|
||||
"You hacked into the bank and received {amount} and an invitation to Anonymous",
|
||||
"You steal {amount} from a child and (narrowly) escape.",
|
||||
"You successfully posted ads in the Red server without Aikaterna catching you, you've earned {amount}.",
|
||||
"You start selling steroids to the players on your team. You manage to make {amount}",
|
||||
"You stole a prized diamond from the nearby bank vault, selling it for {amount}",
|
||||
"You break into a builder's workshop and manage to steal {amount}",
|
||||
"You robbed {amount} from a convenience store.",
|
||||
"You stole a car and sold it for {amount}",
|
||||
"You hacked a bank and stole {amount}",
|
||||
"You steal {amount} from a loan shark, and move to the other side of the world.",
|
||||
"You robbed {amount} from a convenience store.",
|
||||
"You find a wallet on the ground containing {amount} You pick it up and look at the ID inside. You see the man on the ID card running around frantically looking for said wallet. You pocket the wallet and walk away.",
|
||||
"You got a cop drunk and stole their car, selling the parts for {amount}",
|
||||
"You hacked this server and got {amount}",
|
||||
"You do a heist on the EU bank for {amount}",
|
||||
"You are paid {amount} to hit yourself.",
|
||||
"You ransacked your manager's home, found their prized alarm clock, and sold it for {amount}",
|
||||
"You managed to steal an iPhone X and sold it for {amount}",
|
||||
"You robbed a random slut you found on street for {amount} You also got a free service",
|
||||
"You rob a wild bank and manage to steal {amount}",
|
||||
"You rob a gas station of all its fidget spinners. You sell them for {amount} to some 11 year olds.",
|
||||
"You robbed a Kwik-E Mart and cashed out with {amount}",
|
||||
"You hacked into the bank and received {amount} and an invitation to Anonymous",
|
||||
"You stole Justin Bieber's wallet and found {amount} in it.",
|
||||
"A box wobbles & falls from a delivery vehicle, landing right in front of you. Inside you find high-quality cigars. These are worth {amount}",
|
||||
"You start up a detective service for a few days, but when you finally get business you end up robbing your client for {amount}",
|
||||
"You were a hacker and stole robux {amount}",
|
||||
"As you exit your backyard, a dog from down the street bites your leg leaving you with deep cuts on your calf. You stumble with pain and kick the dog into your backyard before closing the gate. Later that day a Lost Dog poster is seen on the street offering a reward. You return the dog, only after receiving your {amount} reward. They shouldn't have bit you on your own property.",
|
||||
"You were going to commit a crime but changed your mind and got a job instead. You made {amount} before your boss realized you were a criminal and fired you.",
|
||||
"You raided the enemy tribe and got {amount}",
|
||||
"You set fire to Starbucks and steal all the coffee worth {amount}",
|
||||
"You sold drugs for {amount}",
|
||||
"You rob the bank of Eternity for {amount}",
|
||||
"You steal {amount} from your boss and don't get caught.",
|
||||
]
|
29
unbelievaboat/functions.py
Normal file
29
unbelievaboat/functions.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
import random
|
||||
|
||||
|
||||
def roll():
|
||||
roll = random.randint(1, 20)
|
||||
if roll == 1:
|
||||
return 0.005
|
||||
if roll > 1 and roll <= 6:
|
||||
return 0.03
|
||||
if roll > 6 and roll <= 8:
|
||||
return 0.10
|
||||
if roll > 8 and roll <= 10:
|
||||
return 0.20
|
||||
if roll > 10 and roll <= 13:
|
||||
return 0.25
|
||||
if roll > 13 and roll <= 16:
|
||||
return 0.4
|
||||
if roll > 16 and roll <= 17:
|
||||
return 0.655
|
||||
if roll > 17 and roll <= 19:
|
||||
return 0.8
|
||||
if roll == 20:
|
||||
return 0.85
|
||||
|
||||
|
||||
def chunks(l, n):
|
||||
"""Yield successive n-sized chunks from l."""
|
||||
for i in range(0, len(l), n):
|
||||
yield l[i : i + n]
|
21
unbelievaboat/info.json
Normal file
21
unbelievaboat/info.json
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"author": [
|
||||
"flare(flare#0001)"
|
||||
],
|
||||
"install_msg": "Unbelievaboat economy commands converted for Red use.",
|
||||
"name": "Unbelievaboat",
|
||||
"disabled": false,
|
||||
"short": "Unbelievaboat economy commands converted for Red use.",
|
||||
"description": "Unbelievaboat economy commands converted for Red use..",
|
||||
"tags": [
|
||||
"economy",
|
||||
"unbelievaboat",
|
||||
"rob",
|
||||
"work"
|
||||
],
|
||||
"requirements": [
|
||||
"tabulate"
|
||||
],
|
||||
"min_bot_version": "3.5.0",
|
||||
"hidden": false
|
||||
}
|
370
unbelievaboat/roulette.py
Normal file
370
unbelievaboat/roulette.py
Normal file
|
@ -0,0 +1,370 @@
|
|||
import asyncio
|
||||
import datetime
|
||||
import random
|
||||
|
||||
import discord
|
||||
import tabulate
|
||||
from redbot.core import bank, checks, commands
|
||||
from redbot.core.errors import BalanceTooHigh
|
||||
from redbot.core.utils.chat_formatting import box, humanize_number, humanize_timedelta
|
||||
|
||||
from .abc import MixinMeta
|
||||
from .checks import check_global_setting_admin, roulette_disabled_check, wallet_disabled_check
|
||||
|
||||
NUMBERS = {
|
||||
0: "green",
|
||||
1: "red",
|
||||
3: "red",
|
||||
5: "red",
|
||||
7: "red",
|
||||
9: "red",
|
||||
12: "red",
|
||||
14: "red",
|
||||
16: "red",
|
||||
18: "red",
|
||||
19: "red",
|
||||
21: "red",
|
||||
23: "red",
|
||||
25: "red",
|
||||
27: "red",
|
||||
30: "red",
|
||||
32: "red",
|
||||
34: "red",
|
||||
36: "red",
|
||||
2: "black",
|
||||
4: "black",
|
||||
6: "black",
|
||||
8: "black",
|
||||
10: "black",
|
||||
11: "black",
|
||||
13: "black",
|
||||
15: "black",
|
||||
17: "black",
|
||||
20: "black",
|
||||
22: "black",
|
||||
24: "black",
|
||||
26: "black",
|
||||
28: "black",
|
||||
29: "black",
|
||||
31: "black",
|
||||
33: "black",
|
||||
35: "black",
|
||||
}
|
||||
|
||||
EMOJIS = {"black": "\u2B1B", "red": "\U0001F7E5", "green": "\U0001F7E9"}
|
||||
|
||||
COLUMNS = [
|
||||
[1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34],
|
||||
[2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35],
|
||||
[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],
|
||||
]
|
||||
|
||||
BET_TYPES = {
|
||||
"red": "color",
|
||||
"black": "color",
|
||||
"1st dozen": "dozen",
|
||||
"2nd dozen": "dozen",
|
||||
"3rd dozen": "dozen",
|
||||
"odd": "odd_or_even",
|
||||
"even": "odd_or_even",
|
||||
"1st half": "halfs",
|
||||
"2nd half": "halfs",
|
||||
"1st column": "column",
|
||||
"2nd column": "column",
|
||||
"3rd column": "column",
|
||||
}
|
||||
|
||||
|
||||
class Roulette(MixinMeta):
|
||||
"""Roulette Game."""
|
||||
|
||||
async def roulettewithdraw(self, ctx, bet):
|
||||
if not await self.walletdisabledcheck(ctx):
|
||||
await self.walletwithdraw(ctx.author, bet)
|
||||
else:
|
||||
await bank.withdraw_credits(ctx.author, bet)
|
||||
|
||||
async def betting(self, ctx, bet, _type):
|
||||
try:
|
||||
_type = int(_type)
|
||||
except ValueError:
|
||||
pass
|
||||
if isinstance(_type, int):
|
||||
if _type < 0 or _type > 36:
|
||||
return {"failed": "Bet must be between 0 and 36."}
|
||||
if _type == 0:
|
||||
for better in self.roulettegames[ctx.guild.id]["zero"]:
|
||||
if better.get(_type, False) and better[_type]["user"] == ctx.author.id:
|
||||
return {"failed": "You cannot make duplicate bets."}
|
||||
try:
|
||||
await self.roulettewithdraw(ctx, bet)
|
||||
except ValueError:
|
||||
return {"failed": "You do not have enough funds to complete this bet."}
|
||||
self.roulettegames[ctx.guild.id]["zero"].append(
|
||||
{_type: {"user": ctx.author.id, "amount": bet}}
|
||||
)
|
||||
return {"sucess": 200}
|
||||
for better in self.roulettegames[ctx.guild.id]["number"]:
|
||||
if better.get(_type, False) and better[_type]["user"] == ctx.author.id:
|
||||
return {"failed": "You cannot make duplicate bets."}
|
||||
self.roulettegames[ctx.guild.id]["number"].append(
|
||||
{_type: {"user": ctx.author.id, "amount": bet}}
|
||||
)
|
||||
try:
|
||||
await self.roulettewithdraw(ctx, bet)
|
||||
except ValueError:
|
||||
return {"failed": "You do not have enough funds to complete this bet."}
|
||||
return {"sucess": 200}
|
||||
if _type.lower() in BET_TYPES:
|
||||
for better in self.roulettegames[ctx.guild.id][BET_TYPES[_type.lower()]]:
|
||||
if (
|
||||
better.get(_type.lower(), False)
|
||||
and better[_type.lower()]["user"] == ctx.author.id
|
||||
):
|
||||
return {"failed": "You cannot make duplicate bets."}
|
||||
try:
|
||||
await self.roulettewithdraw(ctx, bet)
|
||||
except ValueError:
|
||||
return {"failed": "You do not have enough funds to complete this bet."}
|
||||
self.roulettegames[ctx.guild.id][BET_TYPES[_type.lower()]].append(
|
||||
{_type.lower(): {"user": ctx.author.id, "amount": bet}}
|
||||
)
|
||||
return {"sucess": 200}
|
||||
return {"failed": "Not a valid option"}
|
||||
|
||||
async def payout(self, ctx, winningnum, bets):
|
||||
msg = []
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
payouts = await conf.roulette_payouts()
|
||||
color = NUMBERS[winningnum]
|
||||
odd_even = "odd" if winningnum % 2 != 0 else "even"
|
||||
half = "1st half" if winningnum <= 18 else "2nd half"
|
||||
dozen = "N/A"
|
||||
if bets["dozen"]:
|
||||
if winningnum == 0:
|
||||
dozen = "No dozen winning bet."
|
||||
elif winningnum <= 12:
|
||||
dozen = "1st dozen"
|
||||
elif winningnum <= 24:
|
||||
dozen = "2nd dozen"
|
||||
else:
|
||||
dozen = "3rd dozen"
|
||||
column = "N/A"
|
||||
if bets["column"]:
|
||||
if winningnum == 0:
|
||||
pass
|
||||
elif winningnum in COLUMNS[0]:
|
||||
column = "1st column"
|
||||
elif winningnum in COLUMNS[1]:
|
||||
column = "2nd column"
|
||||
else:
|
||||
column = "3rd column"
|
||||
payout_types = {
|
||||
"zero": winningnum,
|
||||
"color": color,
|
||||
"single": winningnum,
|
||||
"odd_or_even": odd_even,
|
||||
"halfs": half,
|
||||
"dozen": dozen,
|
||||
"column": column,
|
||||
}
|
||||
for bettype, value in payout_types.items():
|
||||
for bet in bets[bettype]:
|
||||
bet_type = list(bet.keys())[0]
|
||||
if bet_type == value:
|
||||
betinfo = list(bet.values())[0]
|
||||
user = ctx.guild.get_member(betinfo["user"])
|
||||
payout = betinfo["amount"] + (betinfo["amount"] * payouts[bettype])
|
||||
if not await self.walletdisabledcheck(ctx):
|
||||
user_conf = await self.configglobalcheckuser(user)
|
||||
wallet = await user_conf.wallet()
|
||||
try:
|
||||
await self.walletdeposit(ctx, user, payout)
|
||||
except ValueError:
|
||||
max_bal = await conf.wallet_max()
|
||||
payout = max_bal - wallet
|
||||
else:
|
||||
try:
|
||||
await bank.deposit_credits(user, payout)
|
||||
except BalanceTooHigh as e:
|
||||
payout = e.max_bal - await bank.get_balance(user)
|
||||
await bank.set_balance(user, e.max_bal)
|
||||
msg.append([bet_type, humanize_number(payout), user.display_name])
|
||||
return msg
|
||||
|
||||
@commands.group(invoke_without_command=True)
|
||||
@commands.guild_only()
|
||||
@roulette_disabled_check()
|
||||
async def roulette(self, ctx, amount: int, *, bet):
|
||||
"""Bet on the roulette wheel.
|
||||
|
||||
**Current supported bets**:
|
||||
Single - Any single number.
|
||||
Colors - Red/Black
|
||||
Halfs - 1st/2nd half
|
||||
Even Odd - Even or Odd
|
||||
Dozens - 1st/2nd/3rd Dozen (Groups of 12)
|
||||
Colums - 1st/2nd/3rd Column.
|
||||
- This is based on the English version of the roulette wheel.
|
||||
"""
|
||||
if ctx.guild.id not in self.roulettegames:
|
||||
return await ctx.send(
|
||||
"Start a roulette game using {}roulette start".format(ctx.prefix)
|
||||
)
|
||||
if self.roulettegames[ctx.guild.id]["started"]:
|
||||
return await ctx.send("The wheel is already spinning.")
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
betting = await conf.betting()
|
||||
minbet, maxbet = betting["min"], betting["max"]
|
||||
if minbet != -1:
|
||||
if amount < minbet:
|
||||
return await ctx.send(f"Your bet must be greater than {humanize_number(minbet)}.")
|
||||
if maxbet != -1:
|
||||
if amount > maxbet:
|
||||
return await ctx.send(f"Your bet must be less than {humanize_number(maxbet)}.")
|
||||
betret = await self.betting(ctx, amount, bet)
|
||||
if betret.get("failed") is not None:
|
||||
return await ctx.send(betret["failed"])
|
||||
await ctx.send(
|
||||
f"You've placed a {humanize_number(amount)} {await bank.get_currency_name(ctx.guild)} bet on {bet}."
|
||||
)
|
||||
|
||||
@roulette_disabled_check()
|
||||
@roulette.command(name="start")
|
||||
async def roulette_start(self, ctx):
|
||||
"""Start a game of roulette."""
|
||||
if ctx.guild.id not in self.roulettegames:
|
||||
self.roulettegames[ctx.guild.id] = {
|
||||
"zero": [],
|
||||
"color": [],
|
||||
"single": [],
|
||||
"dozen": [],
|
||||
"odd_or_even": [],
|
||||
"halfs": [],
|
||||
"column": [],
|
||||
"started": False,
|
||||
}
|
||||
else:
|
||||
return await ctx.send("There is already a roulette game on.")
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
time = await conf.roulette_time()
|
||||
await ctx.send(
|
||||
"The roulette wheel will be spun in {} seconds.".format(time), delete_after=time
|
||||
)
|
||||
async with ctx.typing():
|
||||
await asyncio.sleep(time)
|
||||
self.roulettegames[ctx.guild.id]["started"] = True
|
||||
emb = discord.Embed(
|
||||
color=discord.Color.red(),
|
||||
title="Roulette Wheel",
|
||||
description="The wheel begins to spin.",
|
||||
)
|
||||
msg = await ctx.send(embed=emb)
|
||||
await asyncio.sleep(random.randint(3, 8))
|
||||
number = random.randint(0, 36)
|
||||
payouts = await self.payout(ctx, number, self.roulettegames[ctx.guild.id])
|
||||
emoji = EMOJIS[NUMBERS[number]]
|
||||
emb = discord.Embed(
|
||||
color=discord.Color.red(),
|
||||
title="Roulette Wheel",
|
||||
description="The wheel lands on {} {} {}\n\n**Winnings**\n{}".format(
|
||||
NUMBERS[number],
|
||||
number,
|
||||
emoji,
|
||||
(
|
||||
box(
|
||||
tabulate.tabulate(payouts, headers=["Bet", "Amount Won", "User"]),
|
||||
lang="prolog",
|
||||
)
|
||||
if payouts
|
||||
else "None."
|
||||
),
|
||||
),
|
||||
)
|
||||
await msg.edit(embed=emb)
|
||||
del self.roulettegames[ctx.guild.id]
|
||||
|
||||
@checks.admin_or_permissions(manage_guild=True)
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@commands.group()
|
||||
async def rouletteset(self, ctx):
|
||||
"""Manage settings for roulette."""
|
||||
|
||||
@roulette_disabled_check()
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@rouletteset.command()
|
||||
async def time(
|
||||
self,
|
||||
ctx,
|
||||
time: commands.TimedeltaConverter(
|
||||
minimum=datetime.timedelta(seconds=30),
|
||||
maximum=datetime.timedelta(minutes=5),
|
||||
default_unit="seconds",
|
||||
),
|
||||
):
|
||||
"""Set the time for roulette wheel to start spinning."""
|
||||
seconds = time.total_seconds()
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
await conf.roulette_time.set(seconds)
|
||||
await ctx.tick()
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@rouletteset.command()
|
||||
async def toggle(self, ctx):
|
||||
"""Toggle roulette on and off."""
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
toggle = await conf.roulette_toggle()
|
||||
if toggle:
|
||||
await conf.roulette_toggle.set(False)
|
||||
await ctx.send("Roulette has been disabled.")
|
||||
else:
|
||||
await conf.roulette_toggle.set(True)
|
||||
await ctx.send("Roulette has been enabled.")
|
||||
|
||||
@roulette_disabled_check()
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@rouletteset.command()
|
||||
async def payouts(self, ctx, type, payout: int):
|
||||
"""Set payouts for roulette winnings.
|
||||
|
||||
Note: payout is what your prize is multiplied by.
|
||||
Valid types:
|
||||
zero
|
||||
single
|
||||
color
|
||||
dozen
|
||||
odd_or_even
|
||||
halfs
|
||||
column
|
||||
"""
|
||||
types = ["zero", "single", "color", "dozen", "odd_or_even", "halfs", "column"]
|
||||
if type not in types:
|
||||
return await ctx.send(
|
||||
f"That's not a valid payout type. The available types are `{', '.join(types)}`"
|
||||
)
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
async with conf.roulette_payouts() as payouts:
|
||||
payouts[type] = payout
|
||||
await ctx.tick()
|
||||
|
||||
@rouletteset.command(name="settings")
|
||||
async def _settings(self, ctx):
|
||||
"""Roulette Settings."""
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
enabled = await conf.roulette_toggle()
|
||||
payouts = await conf.roulette_payouts()
|
||||
time = await conf.roulette_time()
|
||||
embed = discord.Embed(color=ctx.author.color, title="Roulette Settings")
|
||||
embed.add_field(name="Status", value="Enabled" if enabled else "Disabled")
|
||||
embed.add_field(name="Time to Spin", value=humanize_timedelta(seconds=time))
|
||||
payoutsmsg = "".join(
|
||||
f"**{payout.replace('_', ' ').title()}**: {payouts[payout]}\n"
|
||||
for payout in sorted(payouts, key=lambda x: payouts[x], reverse=True)
|
||||
)
|
||||
|
||||
embed.add_field(name="Payout Settings", value=payoutsmsg)
|
||||
await ctx.send(embed=embed)
|
320
unbelievaboat/settings.py
Normal file
320
unbelievaboat/settings.py
Normal file
|
@ -0,0 +1,320 @@
|
|||
import datetime
|
||||
|
||||
import discord
|
||||
from redbot.core import commands
|
||||
from redbot.core.utils.chat_formatting import humanize_number, humanize_timedelta
|
||||
from redbot.core.utils.menus import DEFAULT_CONTROLS, menu
|
||||
|
||||
from .abc import MixinMeta
|
||||
from .checks import check_global_setting_admin
|
||||
from .functions import chunks
|
||||
|
||||
|
||||
class SettingsMixin(MixinMeta):
|
||||
"""Settings."""
|
||||
|
||||
@commands.group(name="unbset", aliases=["unb-set"])
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
async def unb_set(self, ctx):
|
||||
"""Manage various settings for Unbelievaboat."""
|
||||
|
||||
@commands.guild_only()
|
||||
@unb_set.command(name="cooldown")
|
||||
async def cooldown_set(
|
||||
self,
|
||||
ctx,
|
||||
job,
|
||||
*,
|
||||
time: commands.TimedeltaConverter(
|
||||
minimum=datetime.timedelta(seconds=0),
|
||||
maximum=datetime.timedelta(days=2),
|
||||
default_unit="minutes",
|
||||
),
|
||||
):
|
||||
"""Set the cooldown for the work, crime or rob commands. Minimum cooldown is 30 seconds.
|
||||
|
||||
The time can be formatted as so `1h30m` etc. Valid times are hours, minutes and seconds.
|
||||
"""
|
||||
job = job.lower()
|
||||
if job not in ["work", "crime", "rob", "deposit", "withdraw"]:
|
||||
return await ctx.send("Invalid job.")
|
||||
seconds = time.total_seconds()
|
||||
if seconds < 30:
|
||||
return await ctx.send("The miniumum interval is 30 seconds.")
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
async with conf.cooldowns() as cooldowns:
|
||||
jobcd = {
|
||||
"work": "workcd",
|
||||
"crime": "crimecd",
|
||||
"rob": "robcd",
|
||||
"deposit": "depositcd",
|
||||
"withdraw": "withdrawcd",
|
||||
}
|
||||
cooldowns[jobcd[job]] = int(seconds)
|
||||
await ctx.tick()
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@unb_set.command(name="payout", usage="<work | crime> <min | max> <amount>")
|
||||
async def payout_set(self, ctx, job: str, min_or_max: str, amount: int):
|
||||
"""Set the min or max payout for working or crimes."""
|
||||
if job not in ["work", "crime"]:
|
||||
return await ctx.send("Invalid job.")
|
||||
if min_or_max not in ["max", "min"]:
|
||||
return await ctx.send("You must choose between min or max.")
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
async with conf.payouts() as payouts:
|
||||
payouts[job][min_or_max] = amount
|
||||
await ctx.tick()
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@unb_set.command(name="betting", usage="<min | max> <amount>")
|
||||
async def betting_set(self, ctx, min_or_max: str, amount: int):
|
||||
"""Set the min or max betting amounts."""
|
||||
if min_or_max not in ["max", "min"]:
|
||||
return await ctx.send("You must choose between min or max.")
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
async with conf.betting() as betting:
|
||||
betting[min_or_max] = amount
|
||||
await ctx.tick()
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@unb_set.group(name="wallet")
|
||||
async def wallet_set(self, ctx):
|
||||
"""Wallet Settings."""
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@wallet_set.command(name="toggle", usage="<on_or_off>")
|
||||
async def wallet_toggle(self, ctx, on_or_off: bool):
|
||||
"""Toggle the wallet system."""
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
if on_or_off:
|
||||
await ctx.send("The wallet and rob system has been enabled.")
|
||||
else:
|
||||
await ctx.send("The wallet and rob system has been disabled.")
|
||||
await conf.disable_wallet.set(on_or_off)
|
||||
await ctx.tick()
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@wallet_set.command(name="max")
|
||||
async def wallet_max(self, ctx, amount: int):
|
||||
"""Set the max a wallet can have."""
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
await conf.wallet_max.set(amount)
|
||||
await ctx.tick()
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@unb_set.command(name="failure-rate", usage="<rob | crime> <amount>", aliases=["failurerate"])
|
||||
async def failure_set(self, ctx, job: str, amount: int):
|
||||
"""Set the failure rate for crimes and robbing."""
|
||||
if job not in ["rob", "crime"]:
|
||||
return await ctx.send("Invalid job.")
|
||||
if amount < 50 or amount > 100:
|
||||
return await ctx.send("Amount must be higher than 50 or less than 100")
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
async with conf.failrates() as failrates:
|
||||
failrates[job] = amount
|
||||
await ctx.tick()
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@unb_set.command(name="fine-rate", usage="<min | max> <amount>", aliases=["finerate"])
|
||||
async def fine_set(self, ctx, min_or_max: str, amount: int):
|
||||
"""Set the min or max fine rate for crimes."""
|
||||
if min_or_max not in ["max", "min"]:
|
||||
return await ctx.send("You must choose between min or max.")
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
async with conf.fines() as fines:
|
||||
fines[min_or_max] = amount
|
||||
await ctx.tick()
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@unb_set.command(name="interest-rate", usage="<amount>", aliases=["interestrate"])
|
||||
async def interest_set(self, ctx, amount: int):
|
||||
"""Set the interest rate if unable to pay a fine from wallet."""
|
||||
if amount < 1 or amount > 99:
|
||||
return await ctx.send("Amount must be higher than 1 or less than 99")
|
||||
await self.config.guild(ctx.guild).interest.set(amount)
|
||||
await ctx.tick()
|
||||
|
||||
@commands.guild_only()
|
||||
@check_global_setting_admin()
|
||||
@unb_set.command(name="add-reply")
|
||||
async def add_reply(self, ctx, job, *, reply: str):
|
||||
"""Add a custom reply for working or crime.
|
||||
|
||||
Put {amount} in place of where you want the amount earned to be.
|
||||
"""
|
||||
if job not in ["work", "crime"]:
|
||||
return await ctx.send("Invalid job.")
|
||||
if "{amount}" not in reply:
|
||||
return await ctx.send("{amount} must be present in the reply.")
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
async with conf.replies() as replies:
|
||||
jobreplies = {"work": "workreplies", "crime": "crimereplies"}
|
||||
if reply in replies[jobreplies[job]]:
|
||||
return await ctx.send("That is already a response.")
|
||||
replies[jobreplies[job]].append(reply)
|
||||
ind = replies[jobreplies[job]].index(reply)
|
||||
await ctx.send("Your reply has been added and is reply ID #{}".format(ind))
|
||||
|
||||
@commands.guild_only()
|
||||
@check_global_setting_admin()
|
||||
@unb_set.command(name="del-reply")
|
||||
async def del_reply(self, ctx, job, *, id: int):
|
||||
"""Delete a custom reply."""
|
||||
if job not in ["work", "crime"]:
|
||||
return await ctx.send("Invalid job.")
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
async with conf.replies() as replies:
|
||||
jobreplies = {"work": "workreplies", "crime": "crimereplies"}
|
||||
if not replies[jobreplies[job]]:
|
||||
return await ctx.send("This job has no custom replies.")
|
||||
if id > len(replies[jobreplies[job]]):
|
||||
return await ctx.send("Invalid ID.")
|
||||
replies[jobreplies[job]].pop(id)
|
||||
await ctx.send("Your reply has been removed")
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@unb_set.command(name="list-replies")
|
||||
async def list_reply(self, ctx, job):
|
||||
"""List custom replies."""
|
||||
if job not in ["work", "crime"]:
|
||||
return await ctx.send("Invalid job.")
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
async with conf.replies() as replies:
|
||||
jobreplies = {"work": "workreplies", "crime": "crimereplies"}
|
||||
if not replies[jobreplies[job]]:
|
||||
return await ctx.send("This job has no custom replies.")
|
||||
a = chunks(replies[jobreplies[job]], 10)
|
||||
embeds = []
|
||||
i = 0
|
||||
for item in a:
|
||||
items = []
|
||||
for strings in item:
|
||||
items.append(f"Reply {i}: {strings}")
|
||||
i += 1
|
||||
embed = discord.Embed(colour=discord.Color.red(), description="\n".join(items))
|
||||
embeds.append(embed)
|
||||
if len(embeds) == 1:
|
||||
await ctx.send(embed=embeds[0])
|
||||
else:
|
||||
await menu(ctx, embeds, DEFAULT_CONTROLS)
|
||||
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@unb_set.command(name="default-replies", usage="<enable | disable>")
|
||||
async def default_replies(self, ctx, enable: bool):
|
||||
"""Whether to use the default replies to work and crime."""
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
if enable:
|
||||
await ctx.send("Default replies are enabled.")
|
||||
else:
|
||||
await ctx.send("Default replies are now disabled.")
|
||||
|
||||
await conf.defaultreplies.set(enable)
|
||||
|
||||
@commands.command()
|
||||
@commands.guild_only()
|
||||
async def cooldowns(self, ctx):
|
||||
"""List your remaining cooldowns.."""
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
userconf = await self.configglobalcheckuser(ctx.author)
|
||||
cd = await userconf.cooldowns()
|
||||
jobcd = await conf.cooldowns()
|
||||
if cd["workcd"] is None:
|
||||
workcd = "None"
|
||||
else:
|
||||
time = int(datetime.datetime.utcnow().timestamp()) - cd["workcd"]
|
||||
if time < jobcd["workcd"]:
|
||||
workcd = humanize_timedelta(seconds=jobcd["workcd"] - time)
|
||||
else:
|
||||
workcd = "Ready to use."
|
||||
if cd["crimecd"] is None:
|
||||
crimecd = "Ready to use."
|
||||
else:
|
||||
time = int(datetime.datetime.utcnow().timestamp()) - cd["crimecd"]
|
||||
if time < jobcd["crimecd"]:
|
||||
crimecd = humanize_timedelta(seconds=jobcd["crimecd"] - time)
|
||||
else:
|
||||
crimecd = "Ready to use."
|
||||
if await self.walletdisabledcheck(ctx):
|
||||
robcd = "Disabled."
|
||||
elif cd["robcd"] is None:
|
||||
robcd = "Ready to use."
|
||||
else:
|
||||
time = int(datetime.datetime.utcnow().timestamp()) - cd["robcd"]
|
||||
if time < jobcd["robcd"]:
|
||||
robcd = humanize_timedelta(seconds=jobcd["robcd"] - time)
|
||||
else:
|
||||
robcd = "Ready to use."
|
||||
msg = "Work Cooldown: `{}`\nCrime Cooldown: `{}`\nRob Cooldown: `{}`".format(
|
||||
workcd, crimecd, robcd
|
||||
)
|
||||
await ctx.maybe_send_embed(msg)
|
||||
|
||||
@unb_set.command()
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@commands.bot_has_permissions(embed_links=True)
|
||||
async def settings(self, ctx):
|
||||
"""Current unbelievaboat settings."""
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
data = await conf.all()
|
||||
cooldowns = data["cooldowns"]
|
||||
workcd = humanize_timedelta(seconds=cooldowns["workcd"])
|
||||
robcd = humanize_timedelta(seconds=cooldowns["robcd"])
|
||||
crimecd = humanize_timedelta(seconds=cooldowns["crimecd"])
|
||||
cooldownmsg = "Work Cooldown: `{}`\nCrime Cooldown: `{}`\nRob Cooldown: `{}`".format(
|
||||
workcd, crimecd, robcd
|
||||
)
|
||||
embed = discord.Embed(colour=ctx.author.colour, title="Unbelievaboat Settings")
|
||||
embed.add_field(
|
||||
name="Using Default Replies?",
|
||||
value="Yes" if data["defaultreplies"] else "No",
|
||||
inline=True,
|
||||
)
|
||||
payouts = data["payouts"]
|
||||
crimepayout = f"**Max**: {humanize_number(payouts['crime']['max'])}\n**Min**: {humanize_number(payouts['crime']['min'])}"
|
||||
workpayout = f"**Max**: {humanize_number(payouts['work']['max'])}\n**Min**: {humanize_number(payouts['work']['min'])}"
|
||||
embed.add_field(name="Work Payouts", value=workpayout, inline=True)
|
||||
embed.add_field(name="Crime Payouts", value=crimepayout, inline=True)
|
||||
failrates = data["failrates"]
|
||||
embed.add_field(
|
||||
name="Fail Rates",
|
||||
value=f"**Crime**: {failrates['crime']}%\n**Rob**: {failrates['rob']}%\n**Interest Fee**: {data['interest']}%",
|
||||
inline=True,
|
||||
)
|
||||
fines = data["fines"]
|
||||
embed.add_field(
|
||||
name="Fines",
|
||||
value=f"**Max**: {humanize_number(fines['max'])}\n**Min**: {humanize_number(fines['min'])}",
|
||||
inline=True,
|
||||
)
|
||||
embed.add_field(name="Cooldown Settings", value=cooldownmsg, inline=True)
|
||||
walletsettings = data["disable_wallet"]
|
||||
embed.add_field(
|
||||
name="Wallet Settings",
|
||||
value=(
|
||||
"Disabled."
|
||||
if not walletsettings
|
||||
else f"**Max Balance**: {humanize_number(data['wallet_max'])}\n**Withdraw Cooldown**: {humanize_timedelta(seconds=cooldowns['withdrawcd'])}\n**Deposit Cooldown**: {humanize_timedelta(seconds=cooldowns['depositcd'])}"
|
||||
),
|
||||
inline=True,
|
||||
)
|
||||
minbet = humanize_number(data["betting"]["min"])
|
||||
maxbet = humanize_number(data["betting"]["max"])
|
||||
betstats = f"**Max**: {maxbet}\n**Min**: {minbet}"
|
||||
embed.add_field(name="Betting Information", value=betstats)
|
||||
roulette = data["roulette_toggle"]
|
||||
game_stats = f"**Roulette**: {'Enabled' if roulette else 'Disabled'}"
|
||||
embed.add_field(name="Games", value=game_stats)
|
||||
await ctx.send(embed=embed)
|
414
unbelievaboat/unbelievaboat.py
Normal file
414
unbelievaboat/unbelievaboat.py
Normal file
|
@ -0,0 +1,414 @@
|
|||
import datetime
|
||||
import logging
|
||||
import random
|
||||
from abc import ABC
|
||||
from io import BytesIO
|
||||
from typing import Literal, Optional
|
||||
|
||||
import discord
|
||||
import tabulate
|
||||
from redbot.core import Config, bank, checks, commands
|
||||
from redbot.core.errors import BalanceTooHigh
|
||||
from redbot.core.utils.chat_formatting import humanize_number, humanize_timedelta, pagify
|
||||
|
||||
from .checks import check_global_setting_admin, wallet_disabled_check
|
||||
from .defaultreplies import crimes, work
|
||||
from .functions import roll
|
||||
from .roulette import Roulette
|
||||
from .settings import SettingsMixin
|
||||
from .wallet import Wallet
|
||||
|
||||
log = logging.getLogger("red.flare.unbelievaboat")
|
||||
|
||||
|
||||
class CompositeMetaClass(type(commands.Cog), type(ABC)):
|
||||
"""This allows the metaclass used for proper type detection to coexist with discord.py's
|
||||
metaclass."""
|
||||
|
||||
|
||||
class Unbelievaboat(Wallet, Roulette, SettingsMixin, commands.Cog, metaclass=CompositeMetaClass):
|
||||
"""Unbelievaboat Commands."""
|
||||
|
||||
__version__ = "0.5.10"
|
||||
|
||||
def format_help_for_context(self, ctx):
|
||||
"""Thanks Sinbad."""
|
||||
pre_processed = super().format_help_for_context(ctx)
|
||||
return f"{pre_processed}\nCog Version: {self.__version__}"
|
||||
|
||||
def __init__(self, bot):
|
||||
super().__init__()
|
||||
self.bot = bot
|
||||
defaults = {
|
||||
"cooldowns": {
|
||||
"workcd": 14400,
|
||||
"crimecd": 14400,
|
||||
"robcd": 86400,
|
||||
"withdrawcd": 1,
|
||||
"depositcd": 1,
|
||||
},
|
||||
"defaultreplies": True,
|
||||
"replies": {"crimereplies": [], "workreplies": []},
|
||||
"rob": [],
|
||||
"payouts": {"crime": {"max": 300, "min": 10}, "work": {"max": 250, "min": 10}},
|
||||
"failrates": {"crime": 50, "rob": 70},
|
||||
"fines": {"max": 250, "min": 10},
|
||||
"interest": 5,
|
||||
"disable_wallet": False,
|
||||
"roulette_toggle": True,
|
||||
"roulette_time": 60,
|
||||
"roulette_payouts": {
|
||||
"zero": 36,
|
||||
"single": 17,
|
||||
"color": 1,
|
||||
"dozen": 2,
|
||||
"odd_or_even": 1,
|
||||
"halfs": 1,
|
||||
"column": 2,
|
||||
},
|
||||
"betting": {"max": 10000, "min": 100},
|
||||
"wallet_max": 50000,
|
||||
}
|
||||
defaults_member = {
|
||||
"cooldowns": {
|
||||
"workcd": None,
|
||||
"crimecd": None,
|
||||
"robcd": None,
|
||||
"depositcd": None,
|
||||
"withdrawcd": None,
|
||||
},
|
||||
"wallet": 0,
|
||||
"winnings": 0,
|
||||
"losses": 0,
|
||||
}
|
||||
self.roulettegames = {}
|
||||
self.config = Config.get_conf(self, identifier=95932766180343808, force_registration=True)
|
||||
self.config.register_global(**defaults)
|
||||
self.config.register_guild(**defaults)
|
||||
self.config.register_member(**defaults_member)
|
||||
self.config.register_user(**defaults_member)
|
||||
|
||||
async def red_get_data_for_user(self, *, user_id: int):
|
||||
data = await self.config.user_from_id(user_id).all()
|
||||
all_members = await self.config.all_members()
|
||||
wallets = []
|
||||
for guild_id, member_dict in all_members.items():
|
||||
if user_id in member_dict:
|
||||
usr = await self.config.member_from_ids(guild_id, user_id).all()
|
||||
wallets.append(guild_id, usr["wallet"])
|
||||
contents = f"Unbelievaboat Account for Discord user with ID {user_id}:\n**Global**\n- Wallet: {data['wallet']}\n"
|
||||
if wallets:
|
||||
contents += "**Guilds**"
|
||||
for bal in wallets:
|
||||
contents += f"Guild: {bal[0]} | Wallet: {bal[1]}"
|
||||
return {"user_data.txt": BytesIO(contents.encode())}
|
||||
|
||||
async def red_delete_data_for_user(
|
||||
self,
|
||||
*,
|
||||
requester: Literal["discord_deleted_user", "owner", "user", "user_strict"],
|
||||
user_id: int,
|
||||
):
|
||||
await self.config.user_from_id(user_id).clear()
|
||||
all_members = await self.config.all_members()
|
||||
for guild_id, member_dict in all_members.items():
|
||||
if user_id in member_dict:
|
||||
await self.config.member_from_ids(guild_id, user_id).clear()
|
||||
|
||||
async def configglobalcheck(self, ctx):
|
||||
return self.config if await bank.is_global() else self.config.guild(ctx.guild)
|
||||
|
||||
async def configglobalcheckuser(self, user):
|
||||
if await bank.is_global():
|
||||
return self.config.user(user)
|
||||
return self.config.member(user)
|
||||
|
||||
async def cdcheck(self, ctx, job):
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
userconf = await self.configglobalcheckuser(ctx.author)
|
||||
cd = await userconf.cooldowns()
|
||||
jobcd = await conf.cooldowns()
|
||||
if cd[job] is None:
|
||||
async with userconf.cooldowns() as cd:
|
||||
cd[job] = int(datetime.datetime.now(datetime.timezone.utc).timestamp())
|
||||
return True
|
||||
time = int(datetime.datetime.now(datetime.timezone.utc).timestamp()) - cd[job]
|
||||
if time < jobcd[job]:
|
||||
return (False, humanize_timedelta(seconds=jobcd[job] - time))
|
||||
async with userconf.cooldowns() as cd:
|
||||
cd[job] = int(datetime.datetime.now(datetime.timezone.utc).timestamp())
|
||||
return True
|
||||
|
||||
async def fine(self, ctx, job):
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
fines = await conf.fines()
|
||||
randint = random.randint(fines["min"], fines["max"])
|
||||
amount = str(humanize_number(randint)) + " " + await bank.get_currency_name(ctx.guild)
|
||||
userconf = await self.configglobalcheckuser(ctx.author)
|
||||
if not await self.walletdisabledcheck(ctx):
|
||||
if randint < await userconf.wallet():
|
||||
await self.walletremove(ctx.author, randint)
|
||||
embed = discord.Embed(
|
||||
colour=discord.Color.red(),
|
||||
description=f"\N{NEGATIVE SQUARED CROSS MARK} You were caught by the police and fined {amount}.",
|
||||
)
|
||||
else:
|
||||
interestfee = await self.config.guild(ctx.guild).interest()
|
||||
fee = int(
|
||||
randint * float(f"1.{interestfee if interestfee >= 10 else f'0{interestfee}'}")
|
||||
)
|
||||
if await bank.can_spend(ctx.author, fee):
|
||||
await bank.withdraw_credits(ctx.author, fee)
|
||||
embed = discord.Embed(
|
||||
colour=discord.Color.red(),
|
||||
description=f"\N{NEGATIVE SQUARED CROSS MARK} You were caught by the police and fined {amount}. You did not have enough cash in your wallet and thus it was taken from your bank with a {interestfee}% interest fee ({fee} {await bank.get_currency_name(ctx.guild)}).",
|
||||
)
|
||||
else:
|
||||
await bank.set_balance(ctx.author, 0)
|
||||
embed = discord.Embed(
|
||||
colour=discord.Color.red(),
|
||||
description=f"\N{NEGATIVE SQUARED CROSS MARK} You were caught by the police and fined {amount}. You did not have enough cash to pay the fine and are now bankrupt.",
|
||||
)
|
||||
elif await bank.can_spend(ctx.author, randint):
|
||||
await bank.withdraw_credits(ctx.author, randint)
|
||||
embed = discord.Embed(
|
||||
colour=discord.Color.red(),
|
||||
description=f"\N{NEGATIVE SQUARED CROSS MARK} You were caught by the police and fined {amount}.",
|
||||
)
|
||||
else:
|
||||
if await bank.can_spend(ctx.author, randint):
|
||||
await bank.withdraw_credits(ctx.author, randint)
|
||||
embed = discord.Embed(
|
||||
colour=discord.Color.red(),
|
||||
description=f"\N{NEGATIVE SQUARED CROSS MARK} You were caught by the police and fined {amount}.",
|
||||
)
|
||||
else:
|
||||
await bank.set_balance(ctx.author, 0)
|
||||
embed = discord.Embed(
|
||||
colour=discord.Color.red(),
|
||||
description=f"\N{NEGATIVE SQUARED CROSS MARK} You were caught by the police and fined {amount}. You did not have enough cash to pay the fine and are now bankrupt.",
|
||||
)
|
||||
embed.set_author(name=ctx.author, icon_url=ctx.author.display_avatar.url)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
async def cdnotice(self, user, cooldown, job):
|
||||
response = {
|
||||
"work": f"\N{NEGATIVE SQUARED CROSS MARK} You cannot work for another {cooldown}.",
|
||||
"crime": f"\N{NEGATIVE SQUARED CROSS MARK} You cannot commit a crime for another {cooldown}.",
|
||||
"rob": f"\N{NEGATIVE SQUARED CROSS MARK} You cannot rob a person for another {cooldown}.",
|
||||
"withdraw": f"\N{NEGATIVE SQUARED CROSS MARK} You cannot withdraw any more cash for another {cooldown}.",
|
||||
"deposit": f"\N{NEGATIVE SQUARED CROSS MARK} You cannot deposit any more cash for another {cooldown}.",
|
||||
}
|
||||
embed = discord.Embed(colour=discord.Color.red(), description=response[job])
|
||||
embed.set_author(name=user, icon_url=user.display_avatar)
|
||||
return embed
|
||||
|
||||
@checks.admin_or_permissions(manage_guild=True)
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@commands.command(aliases=["addcashrole"])
|
||||
async def addmoneyrole(
|
||||
self, ctx, amount: int, role: discord.Role, destination: Optional[str] = "wallet"
|
||||
):
|
||||
"""Add money to the balance of all users within a role.
|
||||
|
||||
Valid arguements are 'banks' or 'wallet'.
|
||||
"""
|
||||
if destination.lower() not in ["bank", "wallet"]:
|
||||
return await ctx.send(
|
||||
"You've supplied an invalid destination, you can choose to add it to a bank or their wallet.\nIf no destination is supplied it will default to their wallet."
|
||||
)
|
||||
|
||||
failedmsg = ""
|
||||
if destination.lower() == "bank":
|
||||
for user in role.members:
|
||||
try:
|
||||
await bank.deposit_credits(user, amount)
|
||||
except (ValueError, TypeError) as e:
|
||||
if isinstance(e, ValueError):
|
||||
log.debug(f"Failed to add money to {user} - invalid amount.")
|
||||
else:
|
||||
log.debug(f"Failed to add money to {user} - deposit amount is not an int.")
|
||||
except BalanceTooHigh as e:
|
||||
await bank.set_balance(ctx.author, e.max_balance)
|
||||
failedmsg += f"Failed to add {amount} to {user} due to the max wallet balance limit. Their cash has been set to the max balance.\n"
|
||||
else:
|
||||
for user in role.members:
|
||||
try:
|
||||
await self.walletdeposit(ctx, user, amount)
|
||||
except ValueError:
|
||||
failedmsg += f"Failed to add {amount} to {user} due to the max wallet balance limit. Their cash has been set to the max balance.\n"
|
||||
if failedmsg:
|
||||
for page in pagify(failedmsg):
|
||||
await ctx.send(page)
|
||||
await ctx.tick()
|
||||
|
||||
@checks.admin_or_permissions(manage_guild=True)
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@commands.command(aliases=["removecashrole"])
|
||||
async def removemoneyrole(
|
||||
self, ctx, amount: int, role: discord.Role, destination: Optional[str] = "wallet"
|
||||
):
|
||||
"""Remove money from the bank balance of all users within a role.
|
||||
|
||||
Valid arguements are 'banks' or 'wallet'.
|
||||
"""
|
||||
if destination.lower() not in ["bank", "wallet"]:
|
||||
return await ctx.send(
|
||||
"You've supplied an invalid destination, you can choose to add it to a bank or their wallet.\nIf no destination is supplied it will default to their wallet."
|
||||
)
|
||||
if destination.lower() == "bank":
|
||||
for user in role.members:
|
||||
try:
|
||||
await bank.withdraw_credits(user, amount)
|
||||
except ValueError:
|
||||
await bank.set_balance(user, 0)
|
||||
else:
|
||||
for user in role.members:
|
||||
await self.walletremove(user, amount)
|
||||
await ctx.tick()
|
||||
|
||||
@commands.command()
|
||||
@commands.guild_only()
|
||||
@commands.bot_has_permissions(embed_links=True)
|
||||
async def work(self, ctx):
|
||||
"""Work for some cash."""
|
||||
if ctx.assume_yes:
|
||||
return await ctx.send("This command can't be scheduled.")
|
||||
cdcheck = await self.cdcheck(ctx, "workcd")
|
||||
if isinstance(cdcheck, tuple):
|
||||
embed = await self.cdnotice(ctx.author, cdcheck[1], "work")
|
||||
return await ctx.send(embed=embed)
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
payouts = await conf.payouts()
|
||||
wage = random.randint(payouts["work"]["min"], payouts["work"]["max"])
|
||||
wagesentence = str(humanize_number(wage)) + " " + await bank.get_currency_name(ctx.guild)
|
||||
if await conf.defaultreplies():
|
||||
job = random.choice(work)
|
||||
line = job.format(amount=wagesentence)
|
||||
linenum = work.index(job)
|
||||
else:
|
||||
replies = await conf.replies()
|
||||
if not replies["workreplies"]:
|
||||
return await ctx.send(
|
||||
"You have custom replies enabled yet haven't added any replies yet."
|
||||
)
|
||||
job = random.choice(replies["workreplies"])
|
||||
linenum = replies["workreplies"].index(job)
|
||||
line = job.format(amount=wagesentence)
|
||||
embed = discord.Embed(
|
||||
colour=discord.Color.green(), description=line, timestamp=ctx.message.created_at
|
||||
)
|
||||
embed.set_author(name=ctx.author, icon_url=ctx.author.display_avatar)
|
||||
embed.set_footer(text="Reply #{}".format(linenum))
|
||||
if not await self.walletdisabledcheck(ctx):
|
||||
try:
|
||||
await self.walletdeposit(ctx, ctx.author, wage)
|
||||
except ValueError:
|
||||
embed.description += f"\nYou've reached the maximum amount of {await bank.get_currency_name(ctx.guild)}s in your wallet!"
|
||||
else:
|
||||
try:
|
||||
await bank.deposit_credits(ctx.author, wage)
|
||||
except BalanceTooHigh as e:
|
||||
await bank.set_balance(ctx.author, e.max_balance)
|
||||
embed.description += f"\nYou've reached the maximum amount of {await bank.get_currency_name(ctx.guild)}s in your bank!"
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@commands.command()
|
||||
@commands.guild_only()
|
||||
@commands.bot_has_permissions(embed_links=True)
|
||||
async def crime(self, ctx):
|
||||
"""Commit a crime, more risk but higher payout."""
|
||||
if ctx.assume_yes:
|
||||
return await ctx.send("This command can't be scheduled.")
|
||||
cdcheck = await self.cdcheck(ctx, "crimecd")
|
||||
if isinstance(cdcheck, tuple):
|
||||
embed = await self.cdnotice(ctx.author, cdcheck[1], "crime")
|
||||
return await ctx.send(embed=embed)
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
failrates = await conf.failrates()
|
||||
fail = random.randint(1, 100)
|
||||
if fail < failrates["crime"]:
|
||||
return await self.fine(ctx, "crime")
|
||||
payouts = await conf.payouts()
|
||||
wage = random.randint(payouts["crime"]["min"], payouts["crime"]["max"])
|
||||
wagesentence = str(humanize_number(wage)) + " " + await bank.get_currency_name(ctx.guild)
|
||||
if await conf.defaultreplies():
|
||||
job = random.choice(crimes)
|
||||
line = job.format(amount=wagesentence)
|
||||
linenum = crimes.index(job)
|
||||
else:
|
||||
replies = await conf.replies()
|
||||
if not replies["crimereplies"]:
|
||||
return await ctx.send(
|
||||
"You have custom replies enabled yet haven't added any replies yet."
|
||||
)
|
||||
job = random.choice(replies["crimereplies"])
|
||||
line = job.format(amount=wagesentence)
|
||||
linenum = replies["crimereplies"].index(job)
|
||||
embed = discord.Embed(
|
||||
colour=discord.Color.green(), description=line, timestamp=ctx.message.created_at
|
||||
)
|
||||
embed.set_author(name=ctx.author, icon_url=ctx.author.display_avatar)
|
||||
embed.set_footer(text="Reply #{}".format(linenum))
|
||||
if not await self.walletdisabledcheck(ctx):
|
||||
try:
|
||||
await self.walletdeposit(ctx, ctx.author, wage)
|
||||
except ValueError:
|
||||
embed.description += f"\nYou've reached the maximum amount of {await bank.get_currency_name(ctx.guild)}s in your wallet!"
|
||||
else:
|
||||
try:
|
||||
await bank.deposit_credits(ctx.author, wage)
|
||||
except BalanceTooHigh as e:
|
||||
await bank.set_balance(ctx.author, e.max_balance)
|
||||
embed.description += f"\nYou've reached the maximum amount of {await bank.get_currency_name(ctx.guild)}s in your bank!"
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@commands.command()
|
||||
@commands.guild_only()
|
||||
@wallet_disabled_check()
|
||||
@commands.bot_has_permissions(embed_links=True)
|
||||
async def rob(self, ctx, user: discord.Member):
|
||||
"""Rob another user."""
|
||||
if ctx.assume_yes:
|
||||
return await ctx.send("This command can't be scheduled.")
|
||||
if user == ctx.author:
|
||||
return await ctx.send("Robbing yourself doesn't make much sense.")
|
||||
cdcheck = await self.cdcheck(ctx, "robcd")
|
||||
if isinstance(cdcheck, tuple):
|
||||
embed = await self.cdnotice(ctx.author, cdcheck[1], "rob")
|
||||
return await ctx.send(embed=embed)
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
failrates = await conf.failrates()
|
||||
fail = random.randint(1, 100)
|
||||
if fail < failrates["rob"]:
|
||||
return await self.fine(ctx, "rob")
|
||||
userbalance = await self.walletbalance(user)
|
||||
if userbalance <= 50:
|
||||
finechance = random.randint(1, 10)
|
||||
if finechance <= 5:
|
||||
return await self.fine(ctx, "rob")
|
||||
embed = discord.Embed(
|
||||
colour=discord.Color.red(),
|
||||
description=f"You steal {user.name}'s wallet but there was nothing of value inside.",
|
||||
timestamp=ctx.message.created_at,
|
||||
)
|
||||
embed.set_author(name=ctx.author, icon_url=ctx.author.display_avatar)
|
||||
return await ctx.send(embed=embed)
|
||||
modifier = roll()
|
||||
stolen = random.randint(1, int(userbalance * modifier) + 1)
|
||||
embed = discord.Embed(
|
||||
colour=discord.Color.green(),
|
||||
description=f"You steal {user.name}'s wallet and find {humanize_number(stolen)} inside.",
|
||||
timestamp=ctx.message.created_at,
|
||||
)
|
||||
embed.set_author(name=ctx.author, icon_url=ctx.author.display_avatar)
|
||||
try:
|
||||
await self.walletdeposit(ctx, ctx.author, stolen)
|
||||
await self.walletremove(user, stolen)
|
||||
except ValueError:
|
||||
embed.description += "\nAfter stealing the cash, you notice your wallet is now full!"
|
||||
|
||||
await ctx.send(embed=embed)
|
208
unbelievaboat/wallet.py
Normal file
208
unbelievaboat/wallet.py
Normal file
|
@ -0,0 +1,208 @@
|
|||
from typing import Union
|
||||
|
||||
import discord
|
||||
from redbot.core import bank, commands
|
||||
from redbot.core.errors import BalanceTooHigh
|
||||
from redbot.core.utils.chat_formatting import box, humanize_number
|
||||
from redbot.core.utils.menus import DEFAULT_CONTROLS, menu
|
||||
|
||||
from .abc import MixinMeta
|
||||
from .checks import check_global_setting_admin, roulette_disabled_check, wallet_disabled_check
|
||||
|
||||
|
||||
class Wallet(MixinMeta):
|
||||
"""Wallet Commands."""
|
||||
|
||||
async def walletdisabledcheck(self, ctx):
|
||||
if await bank.is_global():
|
||||
return not await self.config.disable_wallet()
|
||||
return not await self.config.guild(ctx.guild).disable_wallet()
|
||||
|
||||
async def walletdeposit(self, ctx, user, amount):
|
||||
conf = await self.configglobalcheckuser(user)
|
||||
main_conf = await self.configglobalcheck(ctx)
|
||||
wallet = await conf.wallet()
|
||||
max_bal = await main_conf.wallet_max()
|
||||
amount = wallet + amount
|
||||
if amount <= max_bal:
|
||||
await conf.wallet.set(amount)
|
||||
else:
|
||||
await conf.wallet.set(max_bal)
|
||||
raise ValueError
|
||||
|
||||
async def walletremove(self, user, amount):
|
||||
conf = await self.configglobalcheckuser(user)
|
||||
wallet = await conf.wallet()
|
||||
if amount < wallet:
|
||||
await conf.wallet.set(wallet - amount)
|
||||
else:
|
||||
await conf.wallet.set(0)
|
||||
|
||||
async def walletwithdraw(self, user, amount):
|
||||
conf = await self.configglobalcheckuser(user)
|
||||
wallet = await conf.wallet()
|
||||
if amount < wallet:
|
||||
await conf.wallet.set(wallet - amount)
|
||||
else:
|
||||
raise ValueError
|
||||
|
||||
async def walletset(self, user, amount):
|
||||
conf = await self.configglobalcheckuser(user)
|
||||
await conf.wallet.set(amount)
|
||||
|
||||
async def bankdeposit(self, ctx, user, amount):
|
||||
conf = await self.configglobalcheckuser(user)
|
||||
wallet = await conf.wallet()
|
||||
deposit = abs(amount)
|
||||
if deposit > wallet:
|
||||
return await ctx.send("You have insufficent funds to complete this deposit.")
|
||||
try:
|
||||
await bank.deposit_credits(user, deposit)
|
||||
msg = f"You have succesfully deposited {deposit} {await bank.get_currency_name(ctx.guild)} into your bank account."
|
||||
except BalanceTooHigh as e:
|
||||
deposit = e.max_balance - await bank.get_balance(user)
|
||||
await bank.deposit_credits(user, deposit)
|
||||
msg = f"Your transaction was limited to {deposit} {e.currency_name} as your bank account has reached the max balance."
|
||||
await self.walletset(user, wallet - deposit)
|
||||
return await ctx.send(msg)
|
||||
|
||||
async def walletbalance(self, user):
|
||||
conf = await self.configglobalcheckuser(user)
|
||||
return await conf.wallet()
|
||||
|
||||
async def bankwithdraw(self, ctx, user, amount):
|
||||
conf = await self.configglobalcheckuser(user)
|
||||
mainconf = await self.configglobalcheck(ctx)
|
||||
max_bal = await mainconf.wallet_max()
|
||||
wallet = await conf.wallet()
|
||||
try:
|
||||
if wallet + amount > max_bal:
|
||||
return await ctx.send(
|
||||
f"You have attempted to withdraw more cash than the maximum balance allows. The maximum balance is {humanize_number(max_bal)} {await bank.get_currency_name(ctx.guild)}."
|
||||
)
|
||||
await bank.withdraw_credits(user, amount)
|
||||
await self.walletset(user, wallet + amount)
|
||||
return await ctx.send(
|
||||
f"You have succesfully withdrawn {humanize_number(amount)} {await bank.get_currency_name(ctx.guild)} from your bank account."
|
||||
)
|
||||
except ValueError:
|
||||
return await ctx.send("You have insufficent funds to complete this withdrawal.")
|
||||
|
||||
@commands.group()
|
||||
@wallet_disabled_check()
|
||||
@commands.guild_only()
|
||||
async def wallet(self, ctx):
|
||||
"""Wallet commands."""
|
||||
|
||||
@wallet.command()
|
||||
@commands.guild_only()
|
||||
async def balance(self, ctx, user: discord.Member = None):
|
||||
"""Show the user's wallet balance.
|
||||
|
||||
Defaults to yours.
|
||||
"""
|
||||
if user is None:
|
||||
user = ctx.author
|
||||
balance = await self.walletbalance(user)
|
||||
currency = await bank.get_currency_name(ctx.guild)
|
||||
await ctx.send(
|
||||
f"{user.display_name}'s wallet balance is {humanize_number(balance)} {currency}"
|
||||
)
|
||||
|
||||
@wallet.command()
|
||||
@commands.guild_only()
|
||||
async def leaderboard(self, ctx, top: int = 10):
|
||||
"""Print the wallet leaderboard."""
|
||||
if top < 1:
|
||||
top = 10
|
||||
guild = ctx.guild
|
||||
if await bank.is_global():
|
||||
raw_accounts = await self.config.all_users()
|
||||
if guild is not None:
|
||||
tmp = raw_accounts.copy()
|
||||
for acc in tmp:
|
||||
if not guild.get_member(acc):
|
||||
del raw_accounts[acc]
|
||||
else:
|
||||
raw_accounts = await self.config.all_members(guild)
|
||||
walletlist = sorted(raw_accounts.items(), key=lambda x: x[1]["wallet"], reverse=True)[:top]
|
||||
try:
|
||||
bal_len = len(str(walletlist[0][1]["wallet"]))
|
||||
|
||||
except IndexError:
|
||||
return await ctx.send("There are no users with a wallet balance.")
|
||||
pound_len = len(str(len(walletlist)))
|
||||
header = "{pound:{pound_len}}{score:{bal_len}}{name:2}\n".format(
|
||||
pound="#", name="Name", score="Score", bal_len=bal_len + 6, pound_len=pound_len + 3
|
||||
)
|
||||
highscores = []
|
||||
pos = 1
|
||||
temp_msg = header
|
||||
for acc in walletlist:
|
||||
try:
|
||||
name = guild.get_member(acc[0]).display_name
|
||||
except AttributeError:
|
||||
user_id = f"({acc[0]})" if await ctx.bot.is_owner(ctx.author) else ""
|
||||
name = f"{user_id}"
|
||||
balance = acc[1]["wallet"]
|
||||
|
||||
if acc[0] != ctx.author.id:
|
||||
temp_msg += f"{pos}. {balance: <{bal_len + 5}} {name}\n"
|
||||
|
||||
else:
|
||||
temp_msg += f"{pos}. {balance: <{bal_len + 5}} <<{ctx.author.display_name}>>\n"
|
||||
if pos % 10 == 0:
|
||||
highscores.append(box(temp_msg, lang="md"))
|
||||
temp_msg = header
|
||||
pos += 1
|
||||
|
||||
if temp_msg != header:
|
||||
highscores.append(box(temp_msg, lang="md"))
|
||||
|
||||
if highscores:
|
||||
await menu(ctx, highscores, DEFAULT_CONTROLS)
|
||||
|
||||
@wallet_disabled_check()
|
||||
@check_global_setting_admin()
|
||||
@commands.guild_only()
|
||||
@wallet.command(name="set")
|
||||
async def _walletset(self, ctx, user: discord.Member, amount: int):
|
||||
"""Set a users wallet balance."""
|
||||
conf = await self.configglobalcheck(ctx)
|
||||
maxw = await conf.wallet_max()
|
||||
if amount > maxw:
|
||||
return await ctx.send(
|
||||
f"{user.display_name}'s wallet balance cannot rise above {humanize_number(maxw)} {await bank.get_currency_name(ctx.guild)}."
|
||||
)
|
||||
await self.walletset(user, amount)
|
||||
await ctx.send(
|
||||
f"{ctx.author.display_name} has set {user.display_name}'s wallet balance to {humanize_number(amount)} {await bank.get_currency_name(ctx.guild)}."
|
||||
)
|
||||
|
||||
@commands.command()
|
||||
@wallet_disabled_check()
|
||||
@commands.guild_only()
|
||||
@commands.cooldown(1, 5, commands.BucketType.user)
|
||||
async def deposit(self, ctx, amount: Union[int, str]):
|
||||
"""Deposit cash from your wallet to your bank."""
|
||||
cdcheck = await self.cdcheck(ctx, "depositcd")
|
||||
if isinstance(cdcheck, tuple):
|
||||
embed = await self.cdnotice(ctx.author, cdcheck[1], "deposit")
|
||||
return await ctx.send(embed=embed)
|
||||
if isinstance(amount, str):
|
||||
if amount != "all":
|
||||
return await ctx.send("You must provide a valid number or the string `all`.")
|
||||
amount = await self.walletbalance(ctx.author)
|
||||
await self.bankdeposit(ctx, ctx.author, amount)
|
||||
|
||||
@commands.command()
|
||||
@wallet_disabled_check()
|
||||
@commands.guild_only()
|
||||
@commands.cooldown(1, 5, commands.BucketType.user)
|
||||
async def withdraw(self, ctx, amount: int):
|
||||
"""Withdraw cash from your bank to your wallet."""
|
||||
cdcheck = await self.cdcheck(ctx, "withdrawcd")
|
||||
if isinstance(cdcheck, tuple):
|
||||
embed = await self.cdnotice(ctx.author, cdcheck[1], "withdraw")
|
||||
return await ctx.send(embed=embed)
|
||||
await self.bankwithdraw(ctx, ctx.author, amount)
|
Loading…
Add table
Reference in a new issue