This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Benjamin O'Brien
committed
Aug 17, 2020
1 parent
b204f54
commit 3cc0d5b
Showing
9 changed files
with
211 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Prism Rewrite - Basic Command | ||
|
||
# Modules | ||
import discord | ||
from json import loads, dumps | ||
|
||
from assets.prism import Tools | ||
from discord.ext import commands | ||
|
||
# Main Command Class | ||
class Withdraw(commands.Cog): | ||
|
||
def __init__(self, bot): | ||
self.bot = bot | ||
self.desc = "Takes coins in your bank" | ||
self.usage = "withdraw [amount]" | ||
|
||
@commands.command(aliases = ["wd"]) | ||
async def withdraw(self, ctx, amount = None): | ||
|
||
if not amount: | ||
|
||
return await ctx.send(embed = Tools.error("No amount was specified to withdraw.")) | ||
|
||
db = loads(open("db/users", "r").read()) | ||
|
||
user = db[str(ctx.author.id)] | ||
|
||
if not user["bank"]["data"]: | ||
|
||
return await ctx.send(embed = Tools.error("You don't have a bank account, get one with the `bank` command.")) | ||
|
||
if amount == "all": | ||
|
||
amount = user["bank"]["balance"] | ||
|
||
else: | ||
|
||
try: | ||
|
||
amount = int(amount) | ||
|
||
except: | ||
|
||
return await ctx.send(embed = Tools.error("That isn't a valid amount.")) | ||
|
||
if amount > user["bank"]["balance"]: | ||
|
||
return await ctx.send(embed = Tools.error("You don't have that much money in your bank.")) | ||
|
||
user["balance"] += amount | ||
|
||
user["bank"]["balance"] -= amount | ||
|
||
open("db/users", "w").write(dumps(db, indent = 4)) | ||
|
||
if len(str(amount)) > 5: | ||
|
||
a = len(str(amount)) - 5 | ||
|
||
amount = str(amount[:-a]) + ".." | ||
|
||
return await ctx.send(embed = discord.Embed(title = f"{amount} coins withdrew from bank.", color = 0x126bf1)) | ||
|
||
# Link to bot | ||
def setup(bot): | ||
bot.add_cog(Withdraw(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Prism Rewrite - Basic Command | ||
|
||
# Modules | ||
import discord | ||
from json import loads, dumps | ||
|
||
from assets.prism import Tools | ||
from discord.ext import commands | ||
|
||
# Main Command Class | ||
class Trigger(commands.Cog): | ||
|
||
def __init__(self, bot): | ||
self.bot = bot | ||
self.desc = "Text triggers for your server" | ||
self.usage = "trigger [option] [trigger]" | ||
|
||
@commands.command(aliases = ["triggers"]) | ||
async def trigger(self, ctx, option: str = None, *, trigger: str = None): | ||
|
||
db = loads(open("db/guilds", "r").read()) | ||
|
||
_db = db[str(ctx.guild.id)] | ||
|
||
if not option and not trigger: | ||
|
||
triggers = "" | ||
|
||
for trigger in _db["data"]["triggers"]: | ||
|
||
triggers += f"`{trigger}`: {_db['data']['triggers'][trigger]}\n" | ||
|
||
if not triggers: | ||
|
||
triggers = "No triggers on this server." | ||
|
||
embed = discord.Embed(title = "Server Triggers", description = triggers, color = 0x126bf1) | ||
|
||
embed.set_author(name = " | Triggers", icon_url = self.bot.user.avatar_url) | ||
|
||
embed.set_footer(text = f" | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url) | ||
|
||
return await ctx.send(embed = embed) | ||
|
||
elif not trigger: | ||
|
||
return await ctx.send(embed = Tools.error("No option specified; valid options are `add`, and `delete`.")) | ||
|
||
elif option.lower() == "add": | ||
|
||
if not "|" in trigger: | ||
|
||
return await ctx.send(embed = Tools.error("Invalid trigger; `example: haha|no laughing!`.")) | ||
|
||
data = trigger.split("|") | ||
|
||
trigger = data[0] | ||
|
||
response = data[1] | ||
|
||
if not response: | ||
|
||
return await ctx.send(embed = Tools.error("Invalid trigger; `example: haha|no laughing!`.")) | ||
|
||
_db["data"]["triggers"][trigger] = response | ||
|
||
embed = discord.Embed(title = f"Trigger #{len(_db['data']['triggers'])} saved.", color = 0x126bf1) | ||
|
||
elif option.lower() == "delete": | ||
|
||
if not trigger in _db["data"]["triggers"]: | ||
|
||
return await ctx.send(embed = Tools.error("No such trigger exists.")) | ||
|
||
_db["data"]["triggers"].pop(trigger) | ||
|
||
embed = discord.Embed(title = f"Trigger deleted.", color = 0x126bf1) | ||
|
||
else: | ||
|
||
embed = discord.Embed(title = "Invalid option.", description = "Valid options are `add`, and `delete`.", color = 0x126bf1) | ||
|
||
embed.set_author(name = " | Triggers", icon_url = self.bot.user.avatar_url) | ||
|
||
embed.set_footer(text = f" | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url) | ||
|
||
open("db/guilds", "w").write(dumps(db, indent = 4)) | ||
|
||
return await ctx.send(embed = embed) | ||
|
||
# Link to bot | ||
def setup(bot): | ||
bot.add_cog(Trigger(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters