initial cog setup
basic cog functionality with our on join direct message
This commit is contained in:
parent
cbcd0e71a4
commit
853c7a959b
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
5
welcomeCog/__init__.py
Normal file
5
welcomeCog/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from welcome import WelcomeCog
|
||||||
|
from redbot.core.bot import Red
|
||||||
|
|
||||||
|
def setup(bot: Red):
|
||||||
|
bot.add_cog(WelcomeCog(bot))
|
||||||
32
welcomeCog/embedded_message.json
Normal file
32
welcomeCog/embedded_message.json
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"title":"Welcome to the Kanium Discord!",
|
||||||
|
"description":[
|
||||||
|
"\n",
|
||||||
|
"Please ensure to have a look at our #public_info channel and understand who we are and how this place works.",
|
||||||
|
"\n\n",
|
||||||
|
"Additionally it must be mentioned that being on our Discord and playing games with us, does not require Kanium membership. We,",
|
||||||
|
"on the other hand, expect that those who seek to apply for membership show earnestness- in both application and in becoming part of the community"
|
||||||
|
],
|
||||||
|
"color":"0x3399ff",
|
||||||
|
"thumbnail": "https://i.imgur.com/4TLdfDA.png",
|
||||||
|
"fields":[
|
||||||
|
{"id":"text", "name":"Apply to join Kanuim", "value":"!apply applicationText", "inline":"True"},
|
||||||
|
{"id":"text", "name":"Description", "value":"Use this to submit an application for joining Kanium", "inline":"True"},
|
||||||
|
{"id":"text", "name":"Enjoy your stay", "value":"Feel free to hang out in the chat rooms. If you're looking to play a specific game, join that game's chat channel", "inline":"False"},
|
||||||
|
{"id":"links", "name":"Useful information", "value":[
|
||||||
|
"\n",
|
||||||
|
"[KANIUM Website](https://www.kanium.org/)",
|
||||||
|
"\n",
|
||||||
|
"[KANIUM Steam Group](https://steamcommunity.com/groups/Kanium)",
|
||||||
|
"\n",
|
||||||
|
"[KANIUM Twitch Channel](https://twitch.tv/kaniumtv)",
|
||||||
|
"\n",
|
||||||
|
"[KANIUM Open Collective](https://opencollective.com/kanium)"
|
||||||
|
], "inline":"True"},
|
||||||
|
{"id":"text", "name":"Apply to join Kanuim", "value":"!apply applicationText", "inline":"True"}
|
||||||
|
],
|
||||||
|
"footer":{
|
||||||
|
"text":"If you have any questions, please ping a @Recruiter",
|
||||||
|
"icon_url":"https://i.imgur.com/4TLdfDA.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
36
welcomeCog/welcome.py
Normal file
36
welcomeCog/welcome.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
import json
|
||||||
|
|
||||||
|
def fetchMessage():
|
||||||
|
with open('embedded_message.json') as file:
|
||||||
|
try:
|
||||||
|
jsonFormat = json.load(file)
|
||||||
|
print(int(jsonFormat["color"],16))
|
||||||
|
message=discord.Embed(title=str(jsonFormat["title"]), description="".join(map(str, jsonFormat["description"])), color=int(jsonFormat["color"],16))
|
||||||
|
message.set_thumbnail(url=jsonFormat["thumbnail"])
|
||||||
|
for field in jsonFormat["fields"]:
|
||||||
|
if(field["id"]!="links"):
|
||||||
|
message.add_field(name=field["name"], value=field["value"], inline=field["inline"])
|
||||||
|
else:
|
||||||
|
message.add_field(name=field["name"], value="".join(map(str,field["value"])), inline=field["inline"])
|
||||||
|
|
||||||
|
message.set_footer(text=jsonFormat["footer"]["text"], icon_url=jsonFormat["footer"]["icon_url"])
|
||||||
|
return message
|
||||||
|
|
||||||
|
except:
|
||||||
|
return "Welcome To Kanuim !"
|
||||||
|
|
||||||
|
class WelcomeCog(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.message = fetchMessage()
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
@commands.guild_only()
|
||||||
|
async def on_member_join(self, member: discord.Member):
|
||||||
|
try:
|
||||||
|
await member.send(content=None, embed=self.message)
|
||||||
|
except:
|
||||||
|
print(
|
||||||
|
f'Error Occured! sending a dm to {member.display_name} didnt work !')
|
||||||
Loading…
x
Reference in New Issue
Block a user