@@ -15,6 +15,13 @@ _Coming Soon_ | |||
## Changelog | |||
#### v1.6.0 | |||
###### New Features | |||
###### Minor Changes | |||
- Logging is now easier internally. | |||
- The subreddit command has logging. Only when it is being directly invoked and not when an inbuilt command is being used. | |||
###### Bug Fixes | |||
#### v1.5.1 | |||
##### Hot Fixes | |||
- inviteme is hidden and added an extra warning for people not to use it. |
@@ -5,8 +5,7 @@ from discord.ext.commands import bot | |||
from Roxbot import checks | |||
from Roxbot.settings import guild_settings | |||
from Roxbot.logging import Logging | |||
from Roxbot.logging import log | |||
class Fun: | |||
@@ -134,11 +133,11 @@ class Fun: | |||
WIDE_MAP = dict((i, i + 0xFEE0) for i in range(0x21, 0x7F)) | |||
WIDE_MAP[0x20] = 0x3000 | |||
converted = str(convert).translate(WIDE_MAP) | |||
await ctx.send(converted) | |||
logging = guild_settings.get(ctx.guild).logging | |||
if logging["enabled"]: | |||
await Logging(self.bot).log(ctx.guild, "aesthetics", user=ctx.author, argument_given=convert) | |||
return await ctx.send(converted) | |||
log_channel = self.bot.get_channel(logging["channel"]) | |||
await log(ctx.guild, log_channel, "aesthetics", User=ctx.author, Argument_Given=convert, Channel=ctx.channel, Channel_Mention=ctx.channel.mention) | |||
@bot.command(aliases=["ft", "frog"]) | |||
async def frogtips(self, ctx): | |||
@@ -151,5 +150,6 @@ class Fun: | |||
embed.set_footer(text="https://frog.tips") | |||
return await ctx.send(embed=embed) | |||
def setup(bot_client): | |||
bot_client.add_cog(Fun(bot_client)) | |||
bot_client.add_cog(Fun(bot_client)) |
@@ -1,9 +1,13 @@ | |||
from discord.ext.commands import bot | |||
from lxml import html | |||
import random | |||
import requests | |||
from lxml import html | |||
from bs4 import BeautifulSoup | |||
from discord.ext.commands import bot | |||
from Roxbot import checks | |||
from Roxbot.logging import log | |||
from Roxbot.settings import guild_settings | |||
# Warning, this cog sucks so much but hopefully it works and doesn't break the bot too much. Just lazily edited old code and bodged it into this one. | |||
@@ -128,6 +132,12 @@ class Reddit(): | |||
else: | |||
text = "" | |||
if ctx.invoked_with == "subreddit": | |||
# Only log the command when it is this command being used. Not the inbuilt commands. | |||
logging = guild_settings.get(ctx.guild).logging | |||
log_channel = self.bot.get_channel(logging["channel"]) | |||
await log(ctx.guild, log_channel, "subreddit", User=ctx.author, Subreddit=subreddit, Returned="<{}>".format(url), Channel=ctx.channel, Channel_Mention=ctx.channel.mention) | |||
return await ctx.send(title + text + url) | |||
@@ -1,8 +1,17 @@ | |||
import discord | |||
from discord.ext.commands import bot | |||
from Roxbot.settings import guild_settings | |||
from Roxbot.load_config import embedcolour | |||
async def log(guild, channel, command_name, **kwargs): | |||
logging = guild_settings.get(guild).logging | |||
if logging["enabled"]: | |||
embed = discord.Embed(title="{} command logging".format(command_name), colour=embedcolour) | |||
for key, value in kwargs.items(): | |||
embed.add_field(name=key, value=value) | |||
return await channel.send(embed=embed) | |||
class Logging: | |||
def __init__(self, bot_client): | |||
self.bot = bot_client | |||
@@ -27,14 +36,6 @@ class Logging: | |||
embed = discord.Embed(description="{} left the server".format(member), colour=embedcolour) | |||
return await channel.send(embed=embed) | |||
async def log(self, guild, command_name, **kwargs): | |||
logging = guild_settings.get(guild).logging | |||
if logging["enabled"]: | |||
channel = self.bot.get_channel(logging["channel"]) | |||
embed=discord.Embed(title="{} command logging".format(command_name), colour=embedcolour) | |||
for key, value in kwargs.items(): | |||
embed.add_field(name=key, value=value) | |||
return await channel.send(embed=embed) | |||
def setup(bot_client): | |||
bot_client.add_cog(Logging(bot_client)) |