-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7618f0
commit 51b5a9b
Showing
4 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Modified MIT License (MIT) | ||
# | ||
# Copyright (c) 2020 shroomdog27 | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, and sublicense | ||
# the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
from .leaverlogger import LeaverLoggerCog | ||
from redbot.core.bot import Red | ||
|
||
|
||
async def setup(bot: Red) -> None: | ||
await bot.add_cog(LeaverLoggerCog()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"author":[ | ||
"shroomdog27" | ||
], | ||
"name":"LeaverLogger", | ||
"description":"Logs to a join/leave message to a channel when someone leaves a voice channel.", | ||
"min_bot_version":"3.3.10", | ||
"max_bot_version":"0.0.0", | ||
"min_python_version":[ | ||
3, | ||
8, | ||
5 | ||
], | ||
"hidden":false, | ||
"disable":false, | ||
"required_cogs":{ | ||
|
||
}, | ||
"requirements":[ | ||
|
||
], | ||
"tags":[ | ||
"mod", | ||
"logs", | ||
"modlogs" | ||
], | ||
"type":"COG" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Modified MIT License (MIT) | ||
# | ||
# Copyright (c) 2020 shroomdog27 | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, and sublicense | ||
# the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
import discord | ||
import time | ||
from redbot.core import commands as Commands | ||
from redbot.core import Config | ||
from redbot.core.utils.chat_formatting import inline | ||
|
||
|
||
class LeaverLoggerCog(Commands.Cog): | ||
"""My custom cog""" | ||
|
||
def __init__(self): | ||
self.config = Config.get_conf(self, identifier=458459923910065184) | ||
|
||
async def get_channel(self, guild: discord.Guild) -> discord.TextChannel: | ||
txt_id = await self.config.guild(guild).channel() | ||
text_channel = guild.get_channel(txt_id) | ||
return text_channel | ||
|
||
async def set_channel(self, guild: discord.Guild, text_channel_id: int): | ||
await self.config.guild(guild).channel.set(text_channel_id) | ||
|
||
@Commands.group() | ||
@Commands.guild_only() | ||
async def leaverset(self, ctx): | ||
"""Root command for Voice Chat Logger Commands""" | ||
pass | ||
|
||
@leaverset.command(name="channel") | ||
async def leaverset_channel(self, ctx, txt_channel: discord.TextChannel): | ||
"""Sets the text channel to send messages to""" | ||
vc_id = txt_channel.id | ||
await self.set_channel(ctx.guild, vc_id) | ||
await ctx.tick() | ||
return | ||
|
||
@Commands.Cog.listener("on_raw_member_remove") | ||
async def on_raw_member_remove(self, payload: discord.RawMemberRemoveEvent) -> None: | ||
member = payload.user # discord.member.Member | ||
guild = member.guild | ||
|
||
if guild.id != payload.guild_id: | ||
return | ||
|
||
if member.bot: | ||
return | ||
|
||
v_emoji = "⬅️" | ||
v_time = "<t:" + str(int(time.time())) + ":f>" | ||
v_user = "**" + str(member) + "**" | ||
v_action = "has left the server." | ||
|
||
msg = "{emoji} {t_time} {user} {action}".format(emoji=v_emoji, t_time=v_time, user=v_user, action=v_action) | ||
s_channel = await self.get_channel(guild) | ||
await s_channel.send(msg, allowed_mentions=discord.AllowedMentions.none()) | ||
return |