new commands.Context
This commit is contained in:
parent
c36f90698e
commit
3f331e2016
@ -2,8 +2,9 @@ import asyncio
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
from redbot.core import Config, checks
|
from redbot.core import Config, checks
|
||||||
|
from redbot.core import commands
|
||||||
from redbot.core.utils.chat_formatting import pagify, box
|
from redbot.core.utils.chat_formatting import pagify, box
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,8 +2,9 @@ import asyncio
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
from redbot.core import Config
|
from redbot.core import Config
|
||||||
|
from redbot.core import commands
|
||||||
|
|
||||||
from chatter.chatterbot import ChatBot
|
from chatter.chatterbot import ChatBot
|
||||||
from chatter.chatterbot.trainers import ListTrainer
|
from chatter.chatterbot.trainers import ListTrainer
|
||||||
@ -75,7 +76,7 @@ class Chatter:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@commands.group()
|
@commands.group()
|
||||||
async def chatter(self, ctx: RedContext):
|
async def chatter(self, ctx: commands.Context):
|
||||||
"""
|
"""
|
||||||
Base command for this cog. Check help for the commands list.
|
Base command for this cog. Check help for the commands list.
|
||||||
"""
|
"""
|
||||||
@ -83,7 +84,7 @@ class Chatter:
|
|||||||
await ctx.send_help()
|
await ctx.send_help()
|
||||||
|
|
||||||
@chatter.command()
|
@chatter.command()
|
||||||
async def age(self, ctx: RedContext, days: int):
|
async def age(self, ctx: commands.Context, days: int):
|
||||||
"""
|
"""
|
||||||
Sets the number of days to look back
|
Sets the number of days to look back
|
||||||
Will train on 1 day otherwise
|
Will train on 1 day otherwise
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
from redbot.core import Config, checks, RedContext
|
from redbot.core import Config, checks
|
||||||
|
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
|
|
||||||
from pylint import epylint as lint
|
from pylint import epylint as lint
|
||||||
|
from redbot.core import commands
|
||||||
from redbot.core.data_manager import cog_data_path
|
from redbot.core.data_manager import cog_data_path
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ class CogLint:
|
|||||||
self.config.register_guild(**default_guild)
|
self.config.register_guild(**default_guild)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def autolint(self, ctx: RedContext):
|
async def autolint(self, ctx: commands.Context):
|
||||||
"""Toggles automatically linting code"""
|
"""Toggles automatically linting code"""
|
||||||
curr = await self.config.lint()
|
curr = await self.config.lint()
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ class CogLint:
|
|||||||
await ctx.send("Autolinting is now set to {}".format(not curr))
|
await ctx.send("Autolinting is now set to {}".format(not curr))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def lint(self, ctx: RedContext, *, code):
|
async def lint(self, ctx: commands.Context, *, code):
|
||||||
"""Lint python code
|
"""Lint python code
|
||||||
|
|
||||||
Toggle autolinting with `[p]autolint`
|
Toggle autolinting with `[p]autolint`
|
||||||
|
@ -4,7 +4,7 @@ import math
|
|||||||
# from typing import Union
|
# from typing import Union
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
|
|
||||||
from redbot.core.utils.chat_formatting import pagify
|
from redbot.core.utils.chat_formatting import pagify
|
||||||
from redbot.core.utils.chat_formatting import box
|
from redbot.core.utils.chat_formatting import box
|
||||||
|
@ -6,4 +6,4 @@ def setup(bot):
|
|||||||
n = Hangman(bot)
|
n = Hangman(bot)
|
||||||
data_manager.load_bundled_data(n, __file__)
|
data_manager.load_bundled_data(n, __file__)
|
||||||
bot.add_cog(n)
|
bot.add_cog(n)
|
||||||
bot.add_listener(n._on_react, "on_reaction_add")
|
bot.add_listener(n.on_react, "on_reaction_add")
|
||||||
|
@ -2,8 +2,9 @@ from collections import defaultdict
|
|||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
from redbot.core import Config, checks
|
from redbot.core import Config, checks
|
||||||
|
from redbot.core import commands
|
||||||
from redbot.core.data_manager import cog_data_path, load_basic_configuration
|
from redbot.core.data_manager import cog_data_path, load_basic_configuration
|
||||||
|
|
||||||
|
|
||||||
@ -245,7 +246,7 @@ class Hangman:
|
|||||||
|
|
||||||
await self._reprintgame(message)
|
await self._reprintgame(message)
|
||||||
|
|
||||||
async def _on_react(self, reaction, user):
|
async def on_react(self, reaction, user):
|
||||||
""" Thanks to flapjack reactpoll for guidelines
|
""" Thanks to flapjack reactpoll for guidelines
|
||||||
https://github.com/flapjax/FlapJack-Cogs/blob/master/reactpoll/reactpoll.py"""
|
https://github.com/flapjax/FlapJack-Cogs/blob/master/reactpoll/reactpoll.py"""
|
||||||
|
|
||||||
@ -331,8 +332,3 @@ class Hangman:
|
|||||||
await self._reactmessage_menu(message)
|
await self._reactmessage_menu(message)
|
||||||
await self._checkdone(channel)
|
await self._checkdone(channel)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
n = Hangman(bot)
|
|
||||||
bot.add_cog(n)
|
|
||||||
bot.add_listener(n._on_react, "on_reaction_add")
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import discord
|
import discord
|
||||||
|
|
||||||
from discord.ext import commands
|
|
||||||
|
|
||||||
from .utils.chat_formatting import pagify
|
from .utils.chat_formatting import pagify
|
||||||
from .utils.chat_formatting import box
|
from .utils.chat_formatting import box
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import discord
|
import discord
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from discord.ext import commands
|
|
||||||
|
|
||||||
from .utils.dataIO import dataIO
|
from .utils.dataIO import dataIO
|
||||||
from .utils import checks
|
from .utils import checks
|
||||||
|
@ -2,9 +2,10 @@ from datetime import datetime
|
|||||||
|
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
from redbot.core import Config, RedContext
|
from redbot.core import Config
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
|
from redbot.core import commands
|
||||||
|
|
||||||
|
|
||||||
class LastSeen:
|
class LastSeen:
|
||||||
@ -37,13 +38,13 @@ class LastSeen:
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
@commands.group(aliases=['setlseen'], name='lseenset')
|
@commands.group(aliases=['setlseen'], name='lseenset')
|
||||||
async def lset(self, ctx: RedContext):
|
async def lset(self, ctx: commands.Context):
|
||||||
"""Change settings for lseen"""
|
"""Change settings for lseen"""
|
||||||
if ctx.invoked_subcommand is None:
|
if ctx.invoked_subcommand is None:
|
||||||
await ctx.send_help()
|
await ctx.send_help()
|
||||||
|
|
||||||
@lset.command(name="toggle")
|
@lset.command(name="toggle")
|
||||||
async def lset_toggle(self, ctx: RedContext):
|
async def lset_toggle(self, ctx: commands.Context):
|
||||||
"""Toggles tracking seen for this server"""
|
"""Toggles tracking seen for this server"""
|
||||||
enabled = not await self.config.guild(ctx.guild).enabled()
|
enabled = not await self.config.guild(ctx.guild).enabled()
|
||||||
await self.config.guild(ctx.guild).enabled.set(
|
await self.config.guild(ctx.guild).enabled.set(
|
||||||
@ -54,7 +55,7 @@ class LastSeen:
|
|||||||
"Enabled" if enabled else "Disabled"))
|
"Enabled" if enabled else "Disabled"))
|
||||||
|
|
||||||
@commands.command(aliases=['lastseen'])
|
@commands.command(aliases=['lastseen'])
|
||||||
async def lseen(self, ctx: RedContext, member: discord.Member):
|
async def lseen(self, ctx: commands.Context, member: discord.Member):
|
||||||
"""
|
"""
|
||||||
Just says the time the user was last seen
|
Just says the time the user was last seen
|
||||||
|
|
||||||
|
@ -2,10 +2,11 @@ import asyncio
|
|||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
|
|
||||||
from redbot.core import Config
|
from redbot.core import Config
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
|
from redbot.core import commands
|
||||||
|
|
||||||
|
|
||||||
class ReactRestrictCombo:
|
class ReactRestrictCombo:
|
||||||
@ -79,10 +80,6 @@ class ReactRestrict:
|
|||||||
async def add_reactrestrict(self, message_id: int, role: discord.Role):
|
async def add_reactrestrict(self, message_id: int, role: discord.Role):
|
||||||
"""
|
"""
|
||||||
Adds a react|role combo.
|
Adds a react|role combo.
|
||||||
|
|
||||||
:param int message_id:
|
|
||||||
:param str or int emoji:
|
|
||||||
:param discord.Role role:
|
|
||||||
"""
|
"""
|
||||||
# is_custom = True
|
# is_custom = True
|
||||||
# if isinstance(emoji, str):
|
# if isinstance(emoji, str):
|
||||||
@ -177,10 +174,6 @@ class ReactRestrict:
|
|||||||
-> Union[discord.Message, None]:
|
-> Union[discord.Message, None]:
|
||||||
"""
|
"""
|
||||||
Tries to find a message by ID in the current guild context.
|
Tries to find a message by ID in the current guild context.
|
||||||
|
|
||||||
:param ctx:
|
|
||||||
:param message_id:
|
|
||||||
:return:
|
|
||||||
"""
|
"""
|
||||||
channel = self.bot.get_channel(channel_id)
|
channel = self.bot.get_channel(channel_id)
|
||||||
try:
|
try:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import html2text
|
import html2text
|
||||||
from discord.ext import commands
|
|
||||||
from redbot.core import Config, RedContext
|
from redbot.core import Config
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
from redbot.core.utils.chat_formatting import pagify
|
from redbot.core.utils.chat_formatting import pagify
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ class SayUrl:
|
|||||||
self.config.register_guild(**default_guild)
|
self.config.register_guild(**default_guild)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def sayurl(self, ctx: RedContext, url):
|
async def sayurl(self, ctx: commands.Context, url):
|
||||||
"""
|
"""
|
||||||
Converts a URL to something readable
|
Converts a URL to something readable
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
|
|
||||||
from redbot.core import Config
|
from redbot.core import Config
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
|
|
||||||
from redbot.core import Config, RedContext
|
from redbot.core import Config, commands
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
|
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ class StealEmoji:
|
|||||||
self.config.register_global(**default_global)
|
self.config.register_global(**default_global)
|
||||||
|
|
||||||
@commands.group()
|
@commands.group()
|
||||||
async def stealemoji(self, ctx: RedContext):
|
async def stealemoji(self, ctx: commands.Context):
|
||||||
"""
|
"""
|
||||||
Base command for this cog. Check help for the commands list.
|
Base command for this cog. Check help for the commands list.
|
||||||
"""
|
"""
|
||||||
|
@ -3,9 +3,11 @@ from collections import defaultdict
|
|||||||
from random import choice
|
from random import choice
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
|
|
||||||
# Import all roles here
|
# Import all roles here
|
||||||
|
from redbot.core import commands
|
||||||
|
|
||||||
from werewolf.roles.seer import Seer
|
from werewolf.roles.seer import Seer
|
||||||
from werewolf.roles.vanillawerewolf import VanillaWerewolf
|
from werewolf.roles.vanillawerewolf import VanillaWerewolf
|
||||||
from werewolf.roles.villager import Villager
|
from werewolf.roles.villager import Villager
|
||||||
|
@ -2,7 +2,7 @@ import asyncio
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from redbot.core import commands
|
||||||
|
|
||||||
from werewolf.builder import parse_code
|
from werewolf.builder import parse_code
|
||||||
from werewolf.player import Player
|
from werewolf.player import Player
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
from redbot.core import Config, checks
|
from redbot.core import Config, checks
|
||||||
|
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
|
from redbot.core import commands
|
||||||
|
|
||||||
from werewolf.builder import GameBuilder, role_from_name, role_from_alignment, role_from_category, role_from_id
|
from werewolf.builder import GameBuilder, role_from_name, role_from_alignment, role_from_category, role_from_id
|
||||||
from werewolf.game import Game
|
from werewolf.game import Game
|
||||||
|
Loading…
x
Reference in New Issue
Block a user