embedded the file in code
This commit is contained in:
parent
fb6e69b7d9
commit
ff2dec41ea
@ -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": ["requests"],
|
"requirements": [],
|
||||||
"tags": [
|
"tags": [
|
||||||
"welcome"
|
"welcome"
|
||||||
]
|
]
|
||||||
|
|||||||
@ -5,7 +5,40 @@ import json
|
|||||||
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
|
||||||
|
|
||||||
jsonFilePath = 'embedded_message.json'
|
jsonFile = '''\
|
||||||
|
{\
|
||||||
|
"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"\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
'''
|
||||||
|
|
||||||
def fetchMessage(jsonFormat):
|
def fetchMessage(jsonFormat):
|
||||||
try:
|
try:
|
||||||
@ -28,15 +61,12 @@ def fetchMessage(jsonFormat):
|
|||||||
class WelcomeCog(commands.Cog):
|
class WelcomeCog(commands.Cog):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.message = json.load(open(jsonFilePath,'r'))
|
self.message = json.loads(jsonFile)
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_member_join(self, member: discord.Member):
|
async def on_member_join(self, member: discord.Member):
|
||||||
#try:
|
try:
|
||||||
# message = fetchMessage(self.message)
|
message = fetchMessage(self.message)
|
||||||
# await member.send(content=None, embed=message)
|
await member.send(content=None, embed=message)
|
||||||
message = 'helloo'
|
except (discord.NotFound, discord.Forbidden):
|
||||||
await member.send(message)
|
print(f'Error Occured! sending a dm to {member.display_name} didnt work !')
|
||||||
# except (discord.NotFound, discord.Forbidden):
|
|
||||||
# print(
|
|
||||||
# f'Error Occured! sending a dm to {member.display_name} didnt work !')
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user