## Changelog | ## 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 | #### v1.5.1 | ||||
##### Hot Fixes | ##### Hot Fixes | ||||
- inviteme is hidden and added an extra warning for people not to use it. | - inviteme is hidden and added an extra warning for people not to use it. |
from Roxbot import checks | from Roxbot import checks | ||||
from Roxbot.settings import guild_settings | from Roxbot.settings import guild_settings | ||||
from Roxbot.logging import Logging | |||||
from Roxbot.logging import log | |||||
class Fun: | class Fun: | ||||
WIDE_MAP = dict((i, i + 0xFEE0) for i in range(0x21, 0x7F)) | WIDE_MAP = dict((i, i + 0xFEE0) for i in range(0x21, 0x7F)) | ||||
WIDE_MAP[0x20] = 0x3000 | WIDE_MAP[0x20] = 0x3000 | ||||
converted = str(convert).translate(WIDE_MAP) | converted = str(convert).translate(WIDE_MAP) | ||||
await ctx.send(converted) | |||||
logging = guild_settings.get(ctx.guild).logging | 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"]) | @bot.command(aliases=["ft", "frog"]) | ||||
async def frogtips(self, ctx): | async def frogtips(self, ctx): | ||||
embed.set_footer(text="https://frog.tips") | embed.set_footer(text="https://frog.tips") | ||||
return await ctx.send(embed=embed) | return await ctx.send(embed=embed) | ||||
def setup(bot_client): | def setup(bot_client): | ||||
bot_client.add_cog(Fun(bot_client)) | |||||
bot_client.add_cog(Fun(bot_client)) |
from discord.ext.commands import bot | |||||
from lxml import html | |||||
import random | import random | ||||
import requests | import requests | ||||
from lxml import html | |||||
from bs4 import BeautifulSoup | from bs4 import BeautifulSoup | ||||
from discord.ext.commands import bot | |||||
from Roxbot import checks | 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. | # 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. | ||||
else: | else: | ||||
text = "" | 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) | return await ctx.send(title + text + url) | ||||
import discord | import discord | ||||
from discord.ext.commands import bot | |||||
from Roxbot.settings import guild_settings | from Roxbot.settings import guild_settings | ||||
from Roxbot.load_config import embedcolour | 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: | class Logging: | ||||
def __init__(self, bot_client): | def __init__(self, bot_client): | ||||
self.bot = bot_client | self.bot = bot_client | ||||
embed = discord.Embed(description="{} left the server".format(member), colour=embedcolour) | embed = discord.Embed(description="{} left the server".format(member), colour=embedcolour) | ||||
return await channel.send(embed=embed) | 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): | def setup(bot_client): | ||||
bot_client.add_cog(Logging(bot_client)) | bot_client.add_cog(Logging(bot_client)) |