async def prefix(self, ctx, *, pre='+'): if ctx.author.bot == True: return """ Set a custom prefix for a guild """ collection.update_one({"gid":ctx.guild.id}, {"$set":{"prefix": pre}}) await ctx.send('Server prefix is set to `{}`. Use `{}prefix <new_prefix>` to change prefix.'.format(pre,pre))
async def disable(self, ctx): if ctx.author.bot == True: return text = '{mention}, welcome to our server **{server}**. You are {number} member of our server. Please enjoy your stay.' collection.update_one({"gid": ctx.guild.id}, { "$set": { "welcomeChannel": None, "welcomeMessage": text, "welcomeImg": None } }) await ctx.send('welcome messages are disabled.')
async def message(self, ctx, *, message=None): if ctx.author.bot == True: return #print(f'Welcome Message: {message}') if message != None: message = str(message) var = False text = '' string = '' for i in message: if i == '{': var = True continue elif i == '}': string = string.lower() if string == 'user': text += '{' + string + '}' elif string == 'name': text += '{' + string + '}' elif string == 'mention': text += '{' + string + '}' elif string == 'server': text += '{' + string + '}' elif string == 'number': text += '{' + string + '}' else: value = '{' + string + '} is not a valid variable.' await ctx.send(value) return string = '' var = False continue if var == True: string += i else: text += i collection.update_one({"gid": ctx.guild.id}, {"$set": { "welcomeMessage": text }}) await ctx.send( 'welcome message is updated. Use `welcome preview` to see the preview.' ) else: text = '{mention}, welcome to our server **{server}**. You are {number} member of our server. Please enjoy your stay.' collection.update_one({"gid": ctx.guild.id}, {"$set": { "welcomeMessage": text }}) await ctx.send( 'welcome message is set to default. Use `welcome preview` to see the preview.' )
async def channel(self, ctx, channel: discord.TextChannel = None): if ctx.author.bot == True: return if channel == None: await ctx.send('Send a channel.') return try: await channel.send('Welcome messages will be sent here.') collection.update_one({"gid": ctx.guild.id}, {"$set": { "welcomeChannel": channel.id }}) except: await ctx.send( "I don't have permission to send messages in that channel")
async def autorole(self, ctx, role: discord.Role = None): if ctx.author.bot == True: return if role == None: collection.update_one({"gid": ctx.guild.id}, {"$set": { "welcomeRole": None }}) await ctx.send('Autorole is disabled.'.format(role)) return collection.update_one({"gid": ctx.guild.id}, {"$set": { "welcomeRole": role.id }}) await ctx.send('{} is set for autorole'.format(role))
async def image(self, ctx, *, url=None): if ctx.author.bot == True: return if url == None: collection.update_one({"gid": ctx.guild.id}, {"$set": { "welcomeImg": None }}) await ctx.send( 'Welcome Image is disabled.\nNote: Preffered image size is 1000x400.' ) return collection.update_one({"gid": ctx.guild.id}, {"$set": { "welcomeImg": url }}) buffer = await self.welcomeimage(ctx.author, url) await ctx.send( 'Welcome Image is set.\nType `welcome image` to disable it.\nNote: Preffered image size is 1000x400.', file=dFile(fp=buffer, filename='welcome.png'))
async def updatedbconfirm(self, ctx): await ctx.send('Lets go...') if True: query = {} guilds = collection.find(query) for result in guilds: gid = result['gid'] try: collection.update_one({"gid":gid}, {"$set":{'stclaim': 0, 'stdes':0}}) except: #text = '{mention}, welcome to our {server}. You are {number} member. Please enjoy your stay.' #collection.update_one({"gid":gid}, {"$set":{'stclaim': 0, 'stdes':0}}) print('error in claim') await ctx.send('claims added') if True: query = {} users = levelxp.find(query) for result in users: gid = result['gid'] uid = result['uid'] pCards = result['sCards'] #text = '{mention}, welcome to our {server}. You are {number} member. Please enjoy your stay.' levelxp.update_one({"gid":gid,"uid":uid}, {"$set":{'sCards': 0,'pCards':pCards}}) await ctx.send('Season Reset.')
async def setStats(self, ctx): if ctx.author.bot == True: return m = await ctx.send('Please react with 👍 for confirmation') await m.add_reaction('👍') def check(reaction, user): return user == ctx.author and str(reaction.emoji) == '👍' try: reaction, user = await self.bot.wait_for('reaction_add', timeout=20.0, check=check) except asyncio.TimeoutError: await ctx.send('Time Out.') return acount = 0 bcount = 0 mcount = 0 guild = ctx.guild for member in guild.members: if member.bot == True: bcount += 1 else: mcount += 1 acount += 1 overwritee = discord.PermissionOverwrite() overwrite = discord.PermissionOverwrite() category = await ctx.guild.create_category('📊 Server Stats 📊', position=0) overwritee.connect = False overwritee.manage_channels = False overwritee.send_messages = False overwrite.manage_channels = True overwrite.connect = True overwrite.send_messages = True await category.set_permissions(guild.default_role, overwrite=overwritee) await category.set_permissions(self.bot.user, overwrite=overwrite) name = 'All Members: ' + str(acount) channel = await guild.create_voice_channel(name, category=category) await channel.set_permissions(guild.default_role, overwrite=overwritee) await channel.set_permissions(self.bot.user, overwrite=overwrite) cid1 = channel.id name = 'Members: ' + str(mcount) channel = await guild.create_voice_channel(name, category=category) await channel.set_permissions(guild.default_role, overwrite=overwritee) await channel.set_permissions(self.bot.user, overwrite=overwrite) cid2 = channel.id name = 'Bots: ' + str(bcount) channel = await guild.create_voice_channel(name, category=category) await channel.set_permissions(guild.default_role, overwrite=overwritee) await channel.set_permissions(self.bot.user, overwrite=overwrite) cid3 = channel.id collection.update_one( {"gid": ctx.guild.id}, {"$set": { "achannel": cid1, "mchannel": cid2, "bchannel": cid3 }}) await ctx.send( 'Server stats has been created.\nTo disable just delete the channels.' )