· 5 years ago · May 08, 2020, 07:58 PM
1@client.event
2async def on_ready2():
3 db = sqlite3.connect('main.sqlite')
4 cursor = db.cursor()
5 cursor.execute('''
6 CREATE TABLE IF NOT EXISTS main(
7 guild_id TEXT,
8 msg TEXT,
9 channwl_id TEXT
10 )
11 ''')
12
13@client.group(invoke_without_command=True)
14async def welcome(ctx):
15 embed=discord.Embed(description="**Avalible Commands:**\n∘`welcome channel [#channel]`\n∘`welcome text [text]`\n\n**`welcome_help`** For For Information")
16 embed.add_field(name='For Support', value='[Click Here](https://discord.gg/ACEK4ft)')
17 await ctx.send(embed=embed)
18 print('welcome command triggered')
19
20@welcome.command()
21async def channel(ctx, channel:discord.TextChannel):
22 if ctx.message.author.guild_permissions.manage_messages:
23 print('channel command triggerd')
24 db = sqlite3.connect('main.sqlite')
25 cursor = db.cursor()
26 cursor.execute(f"SELECT channel_id FROM main WHERE guild_id = {ctx.guild.id}")
27 result = cursor.fetchone()
28 if result is None:
29 sql = ("INSERT INTO main(guild_id, channel_id) VALUES(?,?)")
30 val = (ctx.guild.id, channel.id)
31 await ctx.send(f'Channel has been set to {channel.mention}')
32 elif result is not None:
33 sql = ("UPDATE main SET channel_id = ? WHERE guild_id = ?")
34 val = (channel.id, ctx.guild.id)
35 embed=discord.Embed(description=f'Channel has been set to {channel.mention} <:success:638755721848160307>', colour=0x33FF69)
36 await ctx.send(embed=embed)
37 cursor.execute(sql, val)
38 db.commit()
39 cursor.close()
40 db.close
41
42@welcome.command()
43async def text(ctx, *, text):
44 if ctx.message.author.guild_permissions.manage_messages:
45 print('channel command triggerd')
46 db = sqlite3.connect('main.sqlite')
47 cursor = db.cursor()
48 cursor.execute(f"SELECT msg FROM main WHERE guild_id = {ctx.guild.id}")
49 result = cursor.fetchone()
50 if result is None:
51 sql = ("INSERT INTO main(guild_id, msg) VALUES(?,?)")
52 val = (ctx.guild.id, text)
53 await ctx.send(f'Text has been set to `{text}`')
54 elif result is not None:
55 sql = ("UPDATE main SET msg = ? WHERE guild_id = ?")
56 val = (text, ctx.guild.id)
57 embed=discord.Embed(description=f'Text has been updated to `{text}` <:success:638755721848160307>', colour=0x33FF69)
58 await ctx.send(embed=embed)
59 cursor.execute(sql, val)
60 db.commit()
61 cursor.close()
62 db.close
63
64@client.command()
65async def welcome_help(ctx):
66 embed = discord.Embed(title='**__Setup Welcome/Leave Messages__**')
67 embed.add_field(name='**Commands**', value='> **》`welcome text [welcome message here]`:**\n> Sets Up Welcome Messages Up For Server\n> **》`welcome channel [#channel]`:**', inline=False)
68 embed.add_field(name='**Variables **', value='> **》`{member.mention}`:**\n> User That Just Joined/Left The Server\n> **》`{member.guild}`:**\n> The Server Name\n> **》`{message.author.id}`:**\n> Users Discord ID', inline=False)
69 embed.set_footer(text='?Included With TRΣV0R Premium')
70 await ctx.send(embed=embed)
71
72@client.event
73async def on_member_join(member):
74 db = sqlite3.connect('main.sqlite')
75 cursor = db.cursor()
76 cursor.execute(f"SELECT msg FROM main WHERE guild_id = {member.guild.id}")
77 result = cursor.fetchone()
78 if result is None:
79 return
80 else:
81 cursor.execute(f"SELECT msg FROM main WHERE guild_id = {member.guild.id}")
82 result1 = cursor.fetchone()
83 members = len(list(member.guild.members))
84 mention = members.mention
85 user = member.name
86 guild = member.guild
87 embed=discord.Embed(description=str(result1[0]).format(members=members, mention=mention, user=user, guild=guild))
88
89 channel = client.get_channel(id=int(result[0]))
90 await channel.send(embed=embed)