changed to a different date system and updated icons and message looks
This commit is contained in:
parent
e1869b95d0
commit
c685e7cf4a
@ -1,20 +1,17 @@
|
|||||||
# WelcomeCog
|
# WelcomeCog
|
||||||
This is the Kanium community/guild welcome cog. it sends a DM to any new user that joins the Kanium discord with a [message](./data/embedded_message.json), which has been templated in a json format.
|
This is the Kanium community/guild welcome cog. it sends a DM to any new user that joins the Kanium discord with a [message](./data/embedded_message.json), which has been templated in a json format.
|
||||||
Furthermore, this cog allows the ability to monitor discord activity and log it into a specific channel using the specific commands. The tracking of the bot resets the daily statistics every 24 hours after the bot has been launched.
|
Furthermore, this cog allows the ability to monitor discord activity and log it into a specific channel using the specific commands.
|
||||||
|
|
||||||
# How to use:
|
# How to use:
|
||||||
|
|
||||||
In order to use our cog you would need to install it onto your instance of [RedBot](https://github.com/Cog-Creators/Red-DiscordBot).
|
In order to use our cog you would need to install it onto your instance of [RedBot](https://github.com/Cog-Creators/Red-DiscordBot).
|
||||||
|
|
||||||
|
|
||||||
## Requirments:
|
## Requirments:
|
||||||
|
|
||||||
- Instance of [RedBot](https://github.com/Cog-Creators/Red-DiscordBot)
|
- Instance of [RedBot](https://github.com/Cog-Creators/Red-DiscordBot)
|
||||||
- Downloader cog has to be loaded. to load:
|
- Downloader cog has to be loaded. to load:
|
||||||
`[Prefix]load downloader`
|
`[Prefix]load downloader`
|
||||||
|
|
||||||
## How to install & load:
|
## How to install & load:
|
||||||
|
|
||||||
1. `[PREFIX]repo add [RepoName] https://github.com/Kanium/KaniumCogs [ActiveBranch (EX: Master)] `
|
1. `[PREFIX]repo add [RepoName] https://github.com/Kanium/KaniumCogs [ActiveBranch (EX: Master)] `
|
||||||
2. `[PREFIX]cog install [RepoName] welcomeCog`
|
2. `[PREFIX]cog install [RepoName] welcomeCog`
|
||||||
3. `[PREFIX]load welcomeCog`
|
3. `[PREFIX]load welcomeCog`
|
||||||
@ -32,11 +29,8 @@ In order to use our cog you would need to install it onto your instance of [RedB
|
|||||||
- `[PREFIX]stats` - prints the statistics that the cog has gathered.
|
- `[PREFIX]stats` - prints the statistics that the cog has gathered.
|
||||||
- `[PREFIX]resetstats` - allows for a hard reset of the stats
|
- `[PREFIX]resetstats` - allows for a hard reset of the stats
|
||||||
- `[PREFIX]toggleLogs` - Toggles the logs functionality on or off
|
- `[PREFIX]toggleLogs` - Toggles the logs functionality on or off
|
||||||
- `[PREFIX]stopScheduler` - Stops the daily reset scheduler
|
|
||||||
- `[PREFIX]startScheduler` - Starts the daily reset scheduler
|
|
||||||
|
|
||||||
### To modify the sent message:
|
### To modify the sent message:
|
||||||
|
|
||||||
If you would like to modify the message to your liking, you can either :
|
If you would like to modify the message to your liking, you can either :
|
||||||
- fork the bot. change the [message](./data/embedded_message.json) and [welcome.py](./welcome.py) line 9 to your repo.
|
- fork the bot. change the [message](./data/embedded_message.json) and [welcome.py](./welcome.py) line 9 to your repo.
|
||||||
- fork the bot. update the [welcome.py](./welcome.py) line 9 to be directed to your message.json file that you like without having it hosted on github with your repo.
|
- fork the bot. update the [welcome.py](./welcome.py) line 9 to be directed to your message.json file that you like without having it hosted on github with your repo.
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
"show earnestness in the submitted application as well as in becoming part of the community."
|
"show earnestness in the submitted application as well as in becoming part of the community."
|
||||||
],
|
],
|
||||||
"color":"0x3399ff",
|
"color":"0x3399ff",
|
||||||
"thumbnail": "https://i.imgur.com/4TLdfDA.png",
|
"thumbnail": "https://www.kanium.org/machineroom/logomodern.png",
|
||||||
"fields":[
|
"fields":[
|
||||||
{"id":"text", "name":"Apply for membership", "value":"!apply <applicationText>", "inline":"True"},
|
{"id":"text", "name":"Apply for membership", "value":"!apply <applicationText>", "inline":"True"},
|
||||||
{"id":"text", "name":"Description", "value":"If you are certain about joining, use this command to do so", "inline":"True"},
|
{"id":"text", "name":"Description", "value":"If you are certain about joining, use this command to do so", "inline":"True"},
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
"name": "Welcome",
|
"name": "Welcome",
|
||||||
"short": "Sends a welcome dm thats written in a specific format to the users",
|
"short": "Sends a welcome dm thats written in a specific format to the users",
|
||||||
"description": "Sends a welcome dm thats written in a specific format to the users",
|
"description": "Sends a welcome dm thats written in a specific format to the users",
|
||||||
"requirements": ["aiohttp"],
|
"requirements": ["aiohttp","datetime"],
|
||||||
"tags": [
|
"tags": [
|
||||||
"welcome"
|
"welcome"
|
||||||
]
|
]
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import asyncio
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import discord
|
import discord
|
||||||
import json
|
import json
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from redbot.core import Config, checks, commands
|
from redbot.core import Config, checks, commands
|
||||||
from redbot.core.utils.chat_formatting import box, humanize_list, pagify
|
from redbot.core.utils.chat_formatting import box, humanize_list, pagify
|
||||||
@ -10,7 +11,7 @@ url = 'https://raw.githubusercontent.com/Kanium/KaniumCogs/master/welcomeCog/dat
|
|||||||
|
|
||||||
allowed_guilds = {274657393936302080, 693796372092289024, 508781789737648138}
|
allowed_guilds = {274657393936302080, 693796372092289024, 508781789737648138}
|
||||||
admin_roles = {'Developer', 'admin', 'Council'}
|
admin_roles = {'Developer', 'admin', 'Council'}
|
||||||
|
statsThumbnailUrl = 'https://www.kanium.org/machineroom/logomachine-small.png'
|
||||||
|
|
||||||
class WelcomeCog(commands.Cog):
|
class WelcomeCog(commands.Cog):
|
||||||
|
|
||||||
@ -24,8 +25,7 @@ class WelcomeCog(commands.Cog):
|
|||||||
self.totalLeftCount: int = 0
|
self.totalLeftCount: int = 0
|
||||||
self.totalLogs: int = 0
|
self.totalLogs: int = 0
|
||||||
self.toggleLogs: bool = True
|
self.toggleLogs: bool = True
|
||||||
self.scheduler: bool = False
|
self.date = datetime.now()
|
||||||
self.task = None
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def fetchMessage():
|
async def fetchMessage():
|
||||||
@ -59,14 +59,16 @@ class WelcomeCog(commands.Cog):
|
|||||||
message = discord.Embed(
|
message = discord.Embed(
|
||||||
title='Kanium', description='', color=0x3399ff)
|
title='Kanium', description='', color=0x3399ff)
|
||||||
message.add_field(
|
message.add_field(
|
||||||
name="Welcome", value='Welcome To Kanium !', inline=True)
|
name='Welcome', value='Welcome To Kanium !', inline=True)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
async def countReset(self):
|
def __checkClock(self):
|
||||||
while True:
|
currdate = self.date - datetime.now()
|
||||||
|
if currdate.day >= 0 :
|
||||||
self.dailyJoinedCount = 0
|
self.dailyJoinedCount = 0
|
||||||
self.dailyLeftCount = 0
|
self.dailyLeftCount = 0
|
||||||
await asyncio.sleep(86400)
|
self.date = datetime.now()
|
||||||
|
|
||||||
|
|
||||||
@commands.command(name='pullmessage', description='pulls the message from github again')
|
@commands.command(name='pullmessage', description='pulls the message from github again')
|
||||||
@commands.has_any_role(*admin_roles)
|
@commands.has_any_role(*admin_roles)
|
||||||
@ -112,12 +114,15 @@ class WelcomeCog(commands.Cog):
|
|||||||
@commands.command(name='stats', description='Shows current statistics')
|
@commands.command(name='stats', description='Shows current statistics')
|
||||||
@commands.has_any_role(*admin_roles)
|
@commands.has_any_role(*admin_roles)
|
||||||
async def statistics(self, ctx: commands.Context) -> None:
|
async def statistics(self, ctx: commands.Context) -> None:
|
||||||
|
self.__checkClock()
|
||||||
await ctx.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
message = '```py\nDaily Joined = {0}\tDaily Left = {1}\nTotal Joined = {2}\tTotal Left = {3}\n------------------------\nTotal Logs = {4}```'.format(
|
statsString = '\nDaily Joined = {0}\tDaily Left = {1}\nTotal Joined = {2}\tTotal Left = {3}\n------------------------\nTotal Logs = {4}'.format(
|
||||||
self.dailyJoinedCount, self.dailyLeftCount, self.totalJoinedCount, self.totalLeftCount, self.totalLogs)
|
self.dailyJoinedCount, self.dailyLeftCount, self.totalJoinedCount, self.totalLeftCount, self.totalLogs)
|
||||||
|
|
||||||
await ctx.send(message)
|
message = discord.Embed(title='Server Traffic Stats', description='Statistics on server activity\n\n'.join(statsString))
|
||||||
|
message.set_thumbnail(url=statsThumbnailUrl)
|
||||||
|
await ctx.send(content=None, embed=message)
|
||||||
|
|
||||||
@commands.command(name='resetstats', description='Resets statistics')
|
@commands.command(name='resetstats', description='Resets statistics')
|
||||||
@commands.has_any_role(*admin_roles)
|
@commands.has_any_role(*admin_roles)
|
||||||
@ -139,31 +144,6 @@ class WelcomeCog(commands.Cog):
|
|||||||
self.toggleLogs = not self.toggleLogs
|
self.toggleLogs = not self.toggleLogs
|
||||||
await ctx.send('Logging functionality is `ON`' if self.toggleLogs else 'Logging functionality is `OFF`')
|
await ctx.send('Logging functionality is `ON`' if self.toggleLogs else 'Logging functionality is `OFF`')
|
||||||
|
|
||||||
@commands.command(name='stopscheduler', description='Stops the daily reset scheduler')
|
|
||||||
@commands.has_any_role(*admin_roles)
|
|
||||||
async def stopScheduler(self, ctx: commands.Context) -> None:
|
|
||||||
await ctx.trigger_typing()
|
|
||||||
|
|
||||||
if not self.scheduler:
|
|
||||||
await ctx.send('Scheduler is already `OFF`')
|
|
||||||
return
|
|
||||||
self.scheduler = False
|
|
||||||
self.task.cancel()
|
|
||||||
self.task = None
|
|
||||||
await ctx.send('Scheduler has been turned `OFF`')
|
|
||||||
|
|
||||||
@commands.command(name='startscheduler', description='Starts the daily reset scheduler')
|
|
||||||
@commands.has_any_role(*admin_roles)
|
|
||||||
async def startScheduler(self, ctx: commands.Context) -> None:
|
|
||||||
await ctx.trigger_typing()
|
|
||||||
|
|
||||||
if self.scheduler:
|
|
||||||
await ctx.send('Scheduler is already `ON`')
|
|
||||||
return
|
|
||||||
self.scheduler = True
|
|
||||||
self.task = self.bot.loop.create_task(self.countReset())
|
|
||||||
await ctx.send('Scheduler has been turned `ON`')
|
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_member_join(self, member: discord.Member) -> None:
|
async def on_member_join(self, member: discord.Member) -> None:
|
||||||
try:
|
try:
|
||||||
@ -173,6 +153,7 @@ class WelcomeCog(commands.Cog):
|
|||||||
self.message = await WelcomeCog.fetchMessage()
|
self.message = await WelcomeCog.fetchMessage()
|
||||||
message = WelcomeCog.formatMessage(self.message)
|
message = WelcomeCog.formatMessage(self.message)
|
||||||
await member.send(content=None, embed=message)
|
await member.send(content=None, embed=message)
|
||||||
|
self.__checkClock()
|
||||||
if self.channel in member.guild.channels and self.toggleLogs:
|
if self.channel in member.guild.channels and self.toggleLogs:
|
||||||
await self.channel.send('>>> {0} has joined the server'.format(member.mention))
|
await self.channel.send('>>> {0} has joined the server'.format(member.mention))
|
||||||
self.totalJoinedCount += 1
|
self.totalJoinedCount += 1
|
||||||
@ -185,6 +166,7 @@ class WelcomeCog(commands.Cog):
|
|||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_member_remove(self, member: discord.Member) -> None:
|
async def on_member_remove(self, member: discord.Member) -> None:
|
||||||
try:
|
try:
|
||||||
|
self.__checkClock()
|
||||||
if self.channel in member.guild.channels and self.toggleLogs:
|
if self.channel in member.guild.channels and self.toggleLogs:
|
||||||
await self.channel.send('>>> {0} has left the server'.format(member.mention))
|
await self.channel.send('>>> {0} has left the server'.format(member.mention))
|
||||||
self.totalLeftCount += 1
|
self.totalLeftCount += 1
|
||||||
@ -197,6 +179,7 @@ class WelcomeCog(commands.Cog):
|
|||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_member_ban(self, guild: discord.Guild, member: discord.Member) -> None:
|
async def on_member_ban(self, guild: discord.Guild, member: discord.Member) -> None:
|
||||||
try:
|
try:
|
||||||
|
self.__checkClock()
|
||||||
if self.channel in member.guild.channels and self.toggleLogs:
|
if self.channel in member.guild.channels and self.toggleLogs:
|
||||||
await self.channel.send('>>> {0} has been banned from the server'.format(member.mention))
|
await self.channel.send('>>> {0} has been banned from the server'.format(member.mention))
|
||||||
self.totalLogs += 1
|
self.totalLogs += 1
|
||||||
@ -207,6 +190,7 @@ class WelcomeCog(commands.Cog):
|
|||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_member_ban(self, guild: discord.Guild, member: discord.Member) -> None:
|
async def on_member_ban(self, guild: discord.Guild, member: discord.Member) -> None:
|
||||||
try:
|
try:
|
||||||
|
self.__checkClock()
|
||||||
if self.channel in member.guild.channels and self.toggleLogs:
|
if self.channel in member.guild.channels and self.toggleLogs:
|
||||||
await self.channel.send('>>> {0} has been unbanned from the server'.format(member.mention))
|
await self.channel.send('>>> {0} has been unbanned from the server'.format(member.mention))
|
||||||
self.totalLogs += 1
|
self.totalLogs += 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user