async def nodm(self, ctx): 'Opt-out of recieving anonymous DMs from the bot.' user = ctx.message.author if user.id not in checks.nodm_ids: checks.nodm_ids.append(user.id) data = functions.read_json('nodm') data['nodm'].append(user.id) functions.write_json('nodm', data) await ctx.send(embed=discord.Embed( title='DMs', description=f'You have opted out of Anonymous DMs.', colour=0xbc0a1d)) print( f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Event] Added {user.name} to the No-DM list.' ) else: checks.nodm_ids.remove(user.id) data = functions.read_json('nodm') data['nodm'].remove(user.id) functions.write_json('nodm', data) await ctx.send(embed=discord.Embed( title='DMs', description=f'You have opted in to Anonymous DMs.', colour=0xbc0a1d)) print( f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Event] Removed {user.name} from the No-DM list.' )
async def blacklist(self, ctx, *, user: discord.User): checks.blacklisted_users.append(user.id) data = functions.read_json('blacklist') data['blacklist'].append(user.id) functions.write_json('blacklist', data) await ctx.send(embed=discord.Embed( description=f'{user.name} has been blacklisted.', colour=0xbc0a1d)) print( f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Event] Added {user.name} to the blacklist.' )
async def setdj(self, ctx, role: discord.Role): dj_roles = functions.read_json('dj_roles') dj_roles[str(ctx.guild.id)] = str(role.id) functions.write_json('dj_roles', dj_roles) em = discord.Embed() em.title = 'DJ Role' em.description = f'Set to: {role.name}' em.colour = 0xbc0a1d await ctx.send(embed=em)
async def setreaction(self, ctx, role: discord.Role = None, msg: discord.Message = None, emoji=None): "Sets a reaction auto-role." if role and msg and emoji: print(emoji) await msg.add_reaction(emoji) self.bot.reaction_roles.append([role.id, msg.id, emoji]) data = functions.read_json('reactionroles') data['reaction_roles'].append([role.id, msg.id, emoji]) functions.write_json('reactionroles', data)
async def on_ready(self): print( f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Client] {self.bot.user.name} is online.' ) game = discord.Game('with your feelings') await self.bot.change_presence(status=discord.Status.online, activity=game) guildCount = len(self.bot.guilds) print( f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Guilds] Bot currently in {guildCount} guilds.' ) for guild in self.bot.guilds: print( f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Guilds] Connected to guild: {guild.name}, Owner: {guild.owner}' ) nodm_data = functions.read_json('nodm') checks.nodm_ids = nodm_data['nodm'] blacklist_data = functions.read_json('blacklist') checks.blacklisted_users = blacklist_data['blacklist'] print( f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Blacklist] Current blacklist:' ) for user_id in checks.blacklisted_users: user = self.bot.get_user(user_id) print( f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Blacklist] - {user.name}' ) global starttime starttime = datetime.datetime.utcnow() reaction_data = functions.read_json('reactionroles') self.bot.reaction_roles = reaction_data['reaction_roles'] '''for file in ['reactionroles.txt']:
async def unblacklist(self, ctx, *, user: discord.User): try: checks.blacklisted_users.remove(user.id) data = functions.read_json('blacklist') data['blacklist'].remove(user.id) functions.write_json('blacklist', data) await ctx.send(embed=discord.Embed( description=f'{user.name} has been unblacklisted.', colour=0xbc0a1d)) print( f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Event] Removed {user.name} from the blacklist.' ) except ValueError: ctx.send(embed=discord.Embed( description=f'{user.name} is not currently blacklisted.', colour=0xbc0a1d))
def main(): print(os.path.dirname(os.getcwd())) # Get the settings fullpath # \\ --> WINDOWS # / --> UNIX #settings_file = os.path.dirname(os.getcwd()) + os.sep + "settings.json" settings_file = os.path.dirname(__file__) + os.sep + "settings.json" # Load json from file json_readed = read_json(fullpath=settings_file) # Load variables from jsons SERVER_RUNNING = json_readed["server_running"] if SERVER_RUNNING: DEBUG = json_readed["debug"] HOST = json_readed["host"] PORT_NUM = json_readed["port"] app.run(debug=DEBUG, host=HOST, port=PORT_NUM) else: print("Server settings.json doesn't allow to start server. " + "Please, allow it to run it.")