· 5 years ago · May 10, 2020, 03:50 PM
1import urllib.request
2import json
3import asyncio
4import os
5import re
6import sys
7import re
8import random
9import time
10import sqlite3
11
12import discord
13from discord import File
14from discord import Game
15from discord.ext import commands
16from discord.ext.commands import Bot
17
18client = commands.Bot(command_prefix = 'pt!')
19client.remove_command("help")
20
21@client.event
22async def on_ready2():
23 db = sqlite3.connect('main.sqlite')
24 cursor = db.cursor()
25 cursor.execute('''
26 CREATE TABLE IF NOT EXISTS main(
27 guild_id TEXT,
28 msg TEXT,
29 channwl_id TEXT
30 )
31 ''')
32
33@client.group(invoke_without_command=True)
34async def welcome(ctx):
35 embed=discord.Embed(description="**Avalible Commands:**\n∘`welcome channel [#channel]`\n∘`welcome text [text]`\n\n**`welcome_help`** For For Information")
36 embed.add_field(name='For Support', value='[Click Here](https://discord.gg/ACEK4ft)')
37 await ctx.send(embed=embed)
38 print('welcome command triggered')
39
40@welcome.command()
41async def channel(ctx, channel:discord.TextChannel):
42 if ctx.message.author.guild_permissions.manage_messages:
43 print('channel command triggerd')
44 db = sqlite3.connect('main.sqlite')
45 cursor = db.cursor()
46 cursor.execute(f"SELECT channel_id FROM main WHERE guild_id = {ctx.guild.id}")
47 result = cursor.fetchone()
48 if result is None:
49 sql = ("INSERT INTO main(guild_id, channel_id) VALUES(?,?)")
50 val = (ctx.guild.id, channel.id)
51 await ctx.send(f'Channel has been set to {channel.mention}')
52 elif result is not None:
53 sql = ("UPDATE main SET channel_id = ? WHERE guild_id = ?")
54 val = (channel.id, ctx.guild.id)
55 embed=discord.Embed(description=f'Channel has been set to {channel.mention} <:success:638755721848160307>', colour=0x33FF69)
56 await ctx.send(embed=embed)
57 cursor.execute(sql, val)
58 db.commit()
59 cursor.close()
60 db.close
61
62@welcome.command()
63async def text(ctx, *, text):
64 if ctx.message.author.guild_permissions.manage_messages:
65 print('channel command triggerd')
66 db = sqlite3.connect('main.sqlite')
67 cursor = db.cursor()
68 cursor.execute(f"SELECT msg FROM main WHERE guild_id = {ctx.guild.id}")
69 result = cursor.fetchone()
70 if result is None:
71 sql = ("INSERT INTO main(guild_id, msg) VALUES(?,?)")
72 val = (ctx.guild.id, text)
73 await ctx.send(f'Text has been set to `{text}`')
74 elif result is not None:
75 sql = ("UPDATE main SET msg = ? WHERE guild_id = ?")
76 val = (text, ctx.guild.id)
77 embed=discord.Embed(description=f'Text has been updated to `{text}` <:success:638755721848160307>', colour=0x33FF69)
78 await ctx.send(embed=embed)
79 cursor.execute(sql, val)
80 db.commit()
81 cursor.close()
82 db.close
83
84@client.command()
85async def welcome_help(ctx):
86 embed = discord.Embed(title='**__Setup Welcome/Leave Messages__**')
87 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)
88 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)
89 await ctx.send(embed=embed)