Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions cogs/cmd/farming.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from discord.ext import commands

from cogs.cmd.common import has_post_permission
from mbot import MiniscapeBotContext


class FarmingCommands:
@commands.group()
async def farm(self, ctx):
pass

@farm.group(name="plant", aliases=["p"])
@commands.check(has_post_permission)
async def _farm_plant(self, ctx: MiniscapeBotContext, *args):
ctx.bot.farm_manager.plant(ctx, args)

@farm.group(name="harvest", aliases=["h"])
@commands.check(has_post_permission)
async def _farm_harvest(self, ctx: MiniscapeBotContext, *args):
ctx.bot.farm_manager.harvest(ctx, args)

@farm.group(name="check", aliases=["ch"])
@commands.check(has_post_permission)
async def _farm_check(self, ctx: MiniscapeBotContext, *args):
ctx.bot.farm_manager.check(ctx, args)

@farm.group(name="clear", aliases=["cl"])
@commands.check(has_post_permission)
async def _farm_clear(self, ctx: MiniscapeBotContext, *args):
ctx.bot.farm_manager.check(ctx, args)
23 changes: 0 additions & 23 deletions cogs/cmd/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,3 @@ async def sell(self, ctx, *args):
if number and item:
out = item_helpers.sell(ctx.author.id, item, number=number)
await ctx.send(out)

#@commands.command()
async def sellall(self, ctx, maxvalue=None):
"""Sells all items in the player's inventory (below a certain value) for gold pieces."""
if has_post_permission(ctx.guild.id, ctx.channel.id):
name = get_display_name(ctx.author)
if maxvalue is not None:
value = users.get_value_of_inventory(ctx.author.id, under=maxvalue)
users.update_inventory(ctx.author.id, value*["0"])
users.clear_inventory(ctx.author.id, under=maxvalue)
value_formatted = '{:,}'.format(value)
maxvalue_formatted = '{:,}'.format(users.parse_int(maxvalue))
name = get_display_name(ctx.author)
out = f"All items in {name}'s inventory worth under {maxvalue_formatted} coins "\
f"sold for {value_formatted} coins!"
else:
value = users.get_value_of_inventory(ctx.author.id)
users.update_inventory(ctx.author.id, value * ["0"])
users.clear_inventory(ctx.author.id)
value_formatted = '{:,}'.format(value)
out = f"All items in {name}'s inventory "\
f"sold for {value_formatted} coins!"
await ctx.send(out)
28 changes: 17 additions & 11 deletions cogs/cmd/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
from discord.ext import commands
from django.db.models import Q

import miniscape.models.user
from cogs.cmd.common import get_display_name, has_post_permission

from cogs.helper import items, users
from cogs.errors.trade_error import TradeError
from mbot import MiniscapeBotContext
from miniscape.models import User, Item
from miniscape.itemconsts import FEDORA, COINS
import miniscape.command_helpers as ch
Expand All @@ -21,21 +23,21 @@ class UserCommands:
This might be themselves (~me) or another user (~examine)"""

@commands.group(invoke_without_command=True)
async def me(self, ctx):
async def me(self, ctx: MiniscapeBotContext):
"""Shows information related to the user."""
if has_post_permission(ctx.guild.id, ctx.channel.id):
await ctx.send(users.print_account(ctx.user_object))
await ctx.send(ctx.user_object.print_account())

@me.group(name='stats', aliases=['levels'])
async def _me_stats(self, ctx):
async def _me_stats(self, ctx: MiniscapeBotContext):
"""Shows the levels and stats of a user."""
if has_post_permission(ctx.guild.id, ctx.channel.id):
await ctx.send(users.print_account(ctx.user_object, printequipment=False))
await ctx.send(ctx.user_object.print_account(print_equipment=False))

@me.group(name='equipment', aliases=['armour', 'armor'])
async def _me_equipment(self, ctx):
async def _me_equipment(self, ctx: MiniscapeBotContext):
if has_post_permission(ctx.guild.id, ctx.channel.id):
await ctx.send(users.print_equipment(ctx.user_object, with_header=True))
await ctx.send(ctx.user_object.print_equipment(with_header=True))

@me.group(name='monsters')
async def _me_monsters(self, ctx, *args):
Expand Down Expand Up @@ -63,20 +65,24 @@ async def examine(self, ctx, *args):
"""Examines a given user."""
if has_post_permission(ctx.guild.id, ctx.channel.id):
search_string = ' '.join(args).lower()
mems = await ctx.guild.query_members(query=search_string)

# This is for loading the guild members. No clue whyt his works
# TODO: Fix and remove?
_ = await ctx.guild.query_members(query=search_string)

for member in ctx.guild.members:
if member.nick is not None:
if search_string in member.nick.lower():
target = User.objects.get(id=member.id)
target: User = User.objects.get(id=member.id)
break
if search_string in member.name.lower():
target = User.objects.get(id=member.id)
target: User = User.objects.get(id=member.id)
break
else:
await ctx.send(f'Could not find {search_string} in server.')
return

await ctx.send(users.print_account(target))
await ctx.send(target.print_account())

@commands.command()
async def tolevel(self, ctx, *args):
Expand All @@ -88,7 +94,7 @@ async def tolevel(self, ctx, *args):
else:
level = None
skill = ' '.join(args)
out = users.calc_xp_to_level(ctx.user_object, skill, level)
out = miniscape.models.user.calc_xp_to_level(ctx.user_object, skill, level)
await ctx.send(out)

@commands.command()
Expand Down
173 changes: 0 additions & 173 deletions cogs/helper/clues.py

This file was deleted.

7 changes: 0 additions & 7 deletions cogs/helper/craft.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import math
import random
import ujson
from collections import Counter

from cogs.helper import items
from cogs.helper import prayer
from cogs.helper import users

ARTISAN_REQ_KEY = 'artisan'
COOKING_REQ_KEY = 'cook'
QUEST_REQ_KEY = 'quest req'
Expand Down
Loading