11import discord
2- import psycopg2
32from typing import Optional
4- from datetime import datetime
5- from discord import Embed , Member
3+ import datetime
64from discord .ext .commands import Cog
75from discord .ext .commands import command
86import os
9- import json
107
118
129class ModSet (Cog ):
1310 def __init__ (self , bot ):
1411 self .bot = bot
1512
1613 @command (name = "modset" , aliases = ["mset" , "modsettings" ])
17- async def modset (self , ctx , target : Optional [Member ]):
14+ async def modset (self , ctx , target : Optional [discord . Member ]):
1815 pass
1916
2017 @command (name = "tags" , aliases = ["tagging" , "msgtag" ], help = "toggles message tags" )
@@ -23,6 +20,7 @@ async def message_tags(self, ctx, switch: Optional[str]):
2320 cur .execute (
2421 'SELECT tag_messages FROM guilds WHERE guild_id = \' ' + str (ctx .guild .id ) + '\' ;' )
2522 tag_messages = cur .fetchone ()
23+ cur .close ()
2624 tag_switch = tag_messages [0 ]
2725 if switch is None :
2826 if tag_switch == "off" :
@@ -35,10 +33,17 @@ async def message_tags(self, ctx, switch: Optional[str]):
3533 tag_switch = "on"
3634
3735 else :
38- embed = Embed (title = "Status" , colour = 0xff0000 ,
39- timestamp = datetime .utcnow ())
40- embed .add_field (
41- name = "Error" , value = "Invalid value provided" , inline = True )
36+ async with ctx .typing ():
37+ embed = discord .Embed (
38+ title = "Status" ,
39+ colour = 0xff0000 ,
40+ timestamp = datetime .datetime .utcnow ()
41+ )
42+ embed .add_field (
43+ name = "Error" ,
44+ value = "Invalid value provided" ,
45+ inline = True
46+ )
4247 await ctx .send (embed = embed )
4348 return
4449
@@ -47,28 +52,34 @@ async def message_tags(self, ctx, switch: Optional[str]):
4752 '\' WHERE guild_id = \' ' + str (ctx .guild .id ) + '\' ;' )
4853 self .bot .DB_CONNECTION .commit ()
4954 cur .close ()
50- embed = Embed (title = "Status" ,
51- colour = 0x00ff00 ,
52- timestamp = datetime .utcnow ())
53- embed .add_field (name = "Done" , value = "Message Tags are now " +
54- tag_switch , inline = True )
55+ async with ctx .typing ():
56+ embed = discord .Embed (
57+ title = "Status" ,
58+ colour = 0x00ff00 ,
59+ timestamp = datetime .datetime .utcnow ()
60+ )
61+ embed .add_field (
62+ name = "Done" ,
63+ value = "Message Tags are now " + tag_switch ,
64+ inline = True
65+ )
5566 await ctx .send (embed = embed )
5667
5768 @command (name = "changepref" , aliases = ["changeprefix" ], help = "changes the prefix to the appended string" )
5869 async def change_prefix (self , ctx , * args ):
5970 prefix = "" .join (args )
60- if ctx .guild .id == int (os .environ ['PUBLIC_BOT_SERVER ' ]):
61- embed = Embed (title = "Status" ,
62- colour = 0xff0000 ,
63- timestamp = datetime .utcnow ())
71+ if ctx .guild .id == int (os .environ ['DEX_PUBLIC_BOT_SERVER ' ]):
72+ embed = discord . Embed (title = "Status" ,
73+ colour = 0xff0000 ,
74+ timestamp = datetime . datetime .utcnow ())
6475 embed .add_field (
6576 name = "Error" , value = "Prefix changes are not allowed on this server!" , inline = True )
6677 await ctx .send (embed = embed )
6778 else :
6879 if ctx .author != ctx .guild .owner :
69- embed = Embed (title = "Status" ,
70- colour = 0xff0000 ,
71- timestamp = datetime .utcnow ())
80+ embed = discord . Embed (title = "Status" ,
81+ colour = 0xff0000 ,
82+ timestamp = datetime . datetime .utcnow ())
7283 embed .add_field (
7384 name = "Error" , value = "Only server owner can change the prefix!" , inline = True )
7485 await ctx .send (embed = embed )
@@ -80,26 +91,26 @@ async def change_prefix(self, ctx, *args):
8091 "\' WHERE guild_id = \' " + str (ctx .guild .id )+ "\' ;" )
8192 self .bot .DB_CONNECTION .commit ()
8293 cur .close ()
83- embed = Embed (title = "Status" ,
84- colour = 0x00ff00 ,
85- timestamp = datetime .utcnow ())
94+ embed = discord . Embed (title = "Status" ,
95+ colour = 0x00ff00 ,
96+ timestamp = datetime . datetime .utcnow ())
8697 embed .add_field (
8798 name = "Done" , value = "New Prefix is " + prefix , inline = True )
8899 await ctx .send (embed = embed )
89100 else :
90- embed = Embed (title = "Status" ,
91- colour = 0xff0000 ,
92- timestamp = datetime .utcnow ())
101+ embed = discord . Embed (title = "Status" ,
102+ colour = 0xff0000 ,
103+ timestamp = datetime . datetime .utcnow ())
93104 embed .add_field (
94105 name = "Error" , value = "prefix length must be between (1 - 27)" , inline = True )
95106 await ctx .send (embed = embed )
96107
97108 @command (name = "goodbye!" , aliases = ["leaveThisServer" ], help = "makes the bot to leave the server (only for server owner)" )
98109 async def leave_this_server (self , ctx ):
99110 if ctx .author != ctx .guild .owner :
100- embed = Embed (title = "Status" ,
101- colour = 0xff0000 ,
102- timestamp = datetime .utcnow ())
111+ embed = discord . Embed (title = "Status" ,
112+ colour = 0xff0000 ,
113+ timestamp = datetime . datetime .utcnow ())
103114 embed .add_field (
104115 name = "Error" , value = "Only server owner can use this command!" , inline = True )
105116 await ctx .send (embed = embed )
@@ -109,7 +120,7 @@ async def leave_this_server(self, ctx):
109120 Had a great time in { ctx .guild .name } !
110121 Now it's time, I guess!
111122 Report any issues: [Here](https://github.com/code-chaser/dex/issues/new)
112- """ , color = 0x8e38ce , timestamp = datetime .utcnow ())
123+ """ , color = 0x8e38ce , timestamp = datetime .datetime . utcnow ())
113124 embed .set_image (
114125 url = "https://user-images.githubusercontent.com/63065397/156924332-3638cd0d-9cf9-4e08-b4de-6f20cedd921a.png" )
115126 embed .set_author (
@@ -134,7 +145,7 @@ async def madeby(self, ctx):
134145 **codechaser#0647**
135146 **[GitHub](https://github.com/code-chaser)**
136147 """ ,
137- color = 0x8e38ce , timestamp = datetime .utcnow ())
148+ color = 0x8e38ce , timestamp = datetime .datetime . utcnow ())
138149 embed .set_author (name = "dex" ,
139150 url = "https://github.com/code-chaser/dex/" , icon_url = self .bot .user .avatar_url )
140151
0 commit comments