Merge pull request #25 from noirscape/cog-fixes

This implements the latest breaking changes to cogs from d.py rewrite.
This commit is contained in:
Ave 2019-03-01 06:51:49 +00:00 committed by GitHub
commit accace3b14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 44 additions and 24 deletions

View file

@ -1,12 +1,13 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
import traceback import traceback
import inspect import inspect
import re import re
from helpers.checks import check_if_bot_manager from helpers.checks import check_if_bot_manager
class Admin: class Admin(Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
self.last_eval_result = None self.last_eval_result = None

View file

@ -2,9 +2,9 @@ import time
import config import config
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
class Basic(Cog):
class Basic:
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View file

@ -5,9 +5,9 @@ import humanize
import time import time
import math import math
import parsedatetime import parsedatetime
from discord.ext.commands import Cog
class Common(Cog):
class Common:
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View file

@ -2,10 +2,10 @@ import re
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
from helpers.errcodes import * from helpers.errcodes import *
class Err(Cog):
class Err:
"""Everything related to Nintendo 3DS, Wii U and Switch error codes""" """Everything related to Nintendo 3DS, Wii U and Switch error codes"""
def __init__(self, bot): def __init__(self, bot):

View file

@ -1,7 +1,7 @@
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
class Legacy(Cog):
class Legacy:
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View file

@ -1,9 +1,9 @@
import discord import discord
import config import config
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
class Links(Cog):
class Links:
""" """
Commands for easily linking to projects. Commands for easily linking to projects.
""" """

View file

@ -1,10 +1,10 @@
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
import config import config
import discord import discord
from helpers.checks import check_if_staff from helpers.checks import check_if_staff
class Lockdown(Cog):
class Lockdown:
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View file

@ -1,11 +1,11 @@
import discord import discord
from discord.ext.commands import Cog
import json import json
import re import re
import config import config
from helpers.restrictions import get_user_restrictions from helpers.restrictions import get_user_restrictions
class Logs(Cog):
class Logs:
""" """
Logs join and leave messages, bans and unbans, and member changes. Logs join and leave messages, bans and unbans, and member changes.
""" """
@ -21,6 +21,7 @@ class Logs:
"nsp", "xci", "nut", "doge", "cdnsp", "lithium"] "nsp", "xci", "nut", "doge", "cdnsp", "lithium"]
self.ok_words = ["nspwn", "hblnsp", "exefs"] self.ok_words = ["nspwn", "hblnsp", "exefs"]
@Cog.listener()
async def on_member_join(self, member): async def on_member_join(self, member):
await self.bot.wait_until_ready() await self.bot.wait_until_ready()
log_channel = self.bot.get_channel(config.log_channel) log_channel = self.bot.get_channel(config.log_channel)
@ -111,6 +112,7 @@ class Logs:
spy_channel = self.bot.get_channel(config.spylog_channel) spy_channel = self.bot.get_channel(config.spylog_channel)
await spy_channel.send(msg) await spy_channel.send(msg)
@Cog.listener()
async def on_message(self, message): async def on_message(self, message):
await self.bot.wait_until_ready() await self.bot.wait_until_ready()
if message.channel.id not in config.spy_channels: if message.channel.id not in config.spy_channels:
@ -118,6 +120,7 @@ class Logs:
await self.do_spy(message) await self.do_spy(message)
@Cog.listener()
async def on_message_edit(self, before, after): async def on_message_edit(self, before, after):
await self.bot.wait_until_ready() await self.bot.wait_until_ready()
if after.channel.id not in config.spy_channels or after.author.bot: if after.channel.id not in config.spy_channels or after.author.bot:
@ -143,6 +146,7 @@ class Logs:
await log_channel.send(msg) await log_channel.send(msg)
@Cog.listener()
async def on_message_delete(self, message): async def on_message_delete(self, message):
await self.bot.wait_until_ready() await self.bot.wait_until_ready()
if message.channel.id not in config.spy_channels or message.author.bot: if message.channel.id not in config.spy_channels or message.author.bot:
@ -161,6 +165,7 @@ class Logs:
await log_channel.send(msg) await log_channel.send(msg)
@Cog.listener()
async def on_member_remove(self, member): async def on_member_remove(self, member):
await self.bot.wait_until_ready() await self.bot.wait_until_ready()
log_channel = self.bot.get_channel(config.log_channel) log_channel = self.bot.get_channel(config.log_channel)
@ -169,6 +174,7 @@ class Logs:
f"🏷 __User ID__: {member.id}" f"🏷 __User ID__: {member.id}"
await log_channel.send(msg) await log_channel.send(msg)
@Cog.listener()
async def on_member_ban(self, guild, member): async def on_member_ban(self, guild, member):
await self.bot.wait_until_ready() await self.bot.wait_until_ready()
log_channel = self.bot.get_channel(config.modlog_channel) log_channel = self.bot.get_channel(config.modlog_channel)
@ -177,6 +183,7 @@ class Logs:
f"🏷 __User ID__: {member.id}" f"🏷 __User ID__: {member.id}"
await log_channel.send(msg) await log_channel.send(msg)
@Cog.listener()
async def on_member_unban(self, guild, user): async def on_member_unban(self, guild, user):
await self.bot.wait_until_ready() await self.bot.wait_until_ready()
log_channel = self.bot.get_channel(config.modlog_channel) log_channel = self.bot.get_channel(config.modlog_channel)
@ -194,6 +201,7 @@ class Logs:
# json.dump(timebans, f) # json.dump(timebans, f)
await log_channel.send(msg) await log_channel.send(msg)
@Cog.listener()
async def on_member_update(self, member_before, member_after): async def on_member_update(self, member_before, member_after):
await self.bot.wait_until_ready() await self.bot.wait_until_ready()
msg = "" msg = ""

View file

@ -1,12 +1,13 @@
import random import random
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
import math import math
import platform import platform
from helpers.checks import check_if_staff_or_ot from helpers.checks import check_if_staff_or_ot
class Meme: class Meme(Cog):
""" """
Meme commands. Meme commands.
""" """

View file

@ -1,5 +1,6 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
import config import config
from helpers.checks import check_if_staff, check_if_bot_manager from helpers.checks import check_if_staff, check_if_bot_manager
from helpers.userlogs import userlog from helpers.userlogs import userlog
@ -7,7 +8,7 @@ from helpers.restrictions import add_restriction, remove_restriction
import io import io
class Mod: class Mod(Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View file

@ -1,10 +1,11 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
from helpers.checks import check_if_staff from helpers.checks import check_if_staff
from helpers.userlogs import userlog from helpers.userlogs import userlog
class ModNote: class ModNote(Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View file

@ -1,11 +1,12 @@
import asyncio import asyncio
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
import config import config
from helpers.checks import check_if_staff from helpers.checks import check_if_staff
class ModReact: class ModReact(Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View file

@ -2,13 +2,14 @@ import discord
import config import config
from datetime import datetime from datetime import datetime
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
from helpers.checks import check_if_staff from helpers.checks import check_if_staff
from helpers.robocronp import add_job from helpers.robocronp import add_job
from helpers.userlogs import userlog from helpers.userlogs import userlog
from helpers.restrictions import add_restriction from helpers.restrictions import add_restriction
class ModTimed: class ModTimed(Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View file

@ -1,12 +1,13 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
import config import config
import json import json
from helpers.checks import check_if_staff from helpers.checks import check_if_staff
from helpers.userlogs import get_userlog, set_userlog, userlog_event_types from helpers.userlogs import get_userlog, set_userlog, userlog_event_types
class ModUserlog: class ModUserlog(Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View file

@ -3,10 +3,11 @@ import asyncio
import time import time
from datetime import datetime from datetime import datetime
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
from helpers.robocronp import add_job, get_crontab from helpers.robocronp import add_job, get_crontab
class Remind: class Remind(Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View file

@ -4,12 +4,13 @@ import time
import discord import discord
import traceback import traceback
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
from helpers.robocronp import get_crontab, delete_job from helpers.robocronp import get_crontab, delete_job
from helpers.restrictions import remove_restriction from helpers.restrictions import remove_restriction
from helpers.checks import check_if_staff from helpers.checks import check_if_staff
class Robocronp: class Robocronp(Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
bot.loop.create_task(self.minutely()) bot.loop.create_task(self.minutely())

View file

@ -1,5 +1,6 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Cog
import asyncio import asyncio
import config import config
import random import random
@ -107,7 +108,7 @@ welcome_footer = (
hidden_term_line = ' • When you have finished reading all of the rules, send a message in this channel that includes the SHA1 hash of your discord "name#discriminator" (for example, User#1234), and we\'ll grant you access to the other channels. You can find your "name#discriminator" (your username followed by a # and four numbers) under the discord channel list.' hidden_term_line = ' • When you have finished reading all of the rules, send a message in this channel that includes the SHA1 hash of your discord "name#discriminator" (for example, User#1234), and we\'ll grant you access to the other channels. You can find your "name#discriminator" (your username followed by a # and four numbers) under the discord channel list.'
class Verification: class Verification(Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@ -225,6 +226,7 @@ class Verification:
no_text = "ugh, wrong, read the rules." no_text = "ugh, wrong, read the rules."
await chan.send(f"{message.author.mention} {no_text}") await chan.send(f"{message.author.mention} {no_text}")
@Cog.listener()
async def on_message(self, message): async def on_message(self, message):
if message.author.bot: if message.author.bot:
return return
@ -235,6 +237,7 @@ class Verification:
chan = self.bot.get_channel(message.channel) chan = self.bot.get_channel(message.channel)
await chan.send("💢 I don't have permission to do this.") await chan.send("💢 I don't have permission to do this.")
@Cog.listener()
async def on_message_edit(self, before, after): async def on_message_edit(self, before, after):
if after.author.bot: if after.author.bot:
return return