async def facepalm(self, ctx, *, Member: BetterMemberConverter = None): Member = Member or ctx.author if Member.id == ctx.author.id: person = self.client.user target = ctx.author if Member.id != ctx.author.id: person = ctx.author target = Member sr_client = sr_api.Client(session=self.client.session) image = await sr_client.get_gif("face-palm") embed = discord.Embed(color=random.randint(0, 16777215)) embed.set_author(name=f"{target} you made {person} facepalm", icon_url=(person.avatar_url)) embed.set_image(url=image.url) embed.set_footer(text="powered by some random api") if isinstance(ctx.channel, discord.TextChannel): await ctx.send(content=target.mention, embed=embed) if isinstance(ctx.channel, discord.DMChannel): if target.dm_channel is None: await target.create_dm() try: await target.send(content=target.mention, embed=embed) except discord.Forbidden: await ctx.author.send("Failed Dming them...")
async def base64(self, ctx, function, *, text): srapi = sr_api.Client() if (function == 'encode'): result = await srapi.encode_base64(text) await ctx.send(result) else: result = await srapi.decode_base64(text) await ctx.send(result)
def __init__(self, bot): self.bot = bot self.engine = cse.Search(self.bot.config['googleapikey']) self.client = sr_api.Client() self.reddit = asyncpraw.Reddit( client_id=self.bot.config['redditauth'][1], client_secret=self.bot.config['redditauth'][0], password=self.bot.config['password'], user_agent=self.bot.config['redditauth'][2], username="******")
async def invert_converter(self, url, ctx): sr_client = sr_api.Client(key=os.environ["sr_key"], session=self.client.session) source_image = sr_client.filter("invert", url=str(url)) image = await source_image.read() imgur_client = aioimgur.ImgurClient(os.environ["imgur_id"], os.environ["imgur_secret"]) imgur_url = await imgur_client.upload(image) embed = discord.Embed(color=random.randint(0, 16777215)) embed.set_author(name=f"Headpat gif requested by {ctx.author}", icon_url=(ctx.author.avatar_url)) embed.set_image(url=imgur_url["link"]) embed.set_footer(text="powered by some random api") await ctx.send(embed=embed)
async def lyrics(self, ctx, *, title): srapi = sr_api.Client() response = await srapi.get_lyrics(title) lyric = response.lyrics finallyric = (lyric[:1020] + '...') if len(lyric) > 1020 else lyric embedColor = random.randint(0, 0xffffff) embed = discord.Embed(title="Lyrics of " + response.title + " by " + response.author + ":", color=embedColor) embed.set_thumbnail(url=response.thumbnail) embed.add_field(name=response.title, value=finallyric, inline=True) embed.add_field(name='Full lyrics: ', value=response.link, inline=False) await ctx.send(embed=embed)
async def triggered_converter(self, url, ctx): sr_client = sr_api.Client(session=self.client.session) source_image = sr_client.filter(option="triggered", url=str(url)) imgur_client = aioimgur.ImgurClient(os.environ["imgur_id"], os.environ["imgur_secret"]) imgur_url = await imgur_client.upload_from_url(source_image.url) embed = discord.Embed(color=random.randint(0, 16777215)) embed.set_author( name=f"Triggered gif requested by {ctx.author}", icon_url=(ctx.author.avatar_url), ) embed.set_image(url=imgur_url["link"]) embed.set_footer(text="powered by some random api") await ctx.send(embed=embed)
async def setup_hook(self) -> None: self.session: ClientSession = ClientSession() self.cache: Cache = Cache(self) self.pool: asyncpg.Pool = await asyncpg.create_pool( **self.settings["postgresql"]) self.topgg: DBLClient = DBLClient(self, self.api["TopGG"], autopost_interval=None, session=self.session) self.topgg_webhook: WebhookManager = WebhookManager(self).dbl_webhook( "/dbl", self.api["TopGGWH"]) self.gist: asyncgist.Client = asyncgist.Client(self.api["GitHub"], self.session) self.sr: sr_api.Client = sr_api.Client() self.dagpi: asyncdagpi.Client = asyncdagpi.Client(self.api["DagpiAPI"], session=self.session) self.myst: mystbin.Client = mystbin.Client(session=self.session) self.loop.create_task(self.cache.populate_cache()) self.loop.create_task(self.load_extensions()) self.loop.create_task(self.start_nodes()) self.loop.create_task(self.find_restart_message()) self.topgg_webhook.run(8025)
def __init__(self, bot: Amaya): self.bot = bot self.api = sr_api.Client(session=self.bot.session)
import random from io import BytesIO import discord import sr_api from discord.ext import commands client = sr_api.Client() class RNG(commands.Cog): """These are commands from Some Random API""" def __init__(self, bot): self.bot = bot self.animals = [ 'cat', 'dog', 'koala', 'fox', 'birb', 'red_panda', 'panda', 'racoon', 'kangaroo' ] self._8ball_responses = [ 'It is certain.', 'It is decidedly so.', 'Without a doubt.', 'Yes - definitely.', 'You may rely on it.', 'As I see it, yes.', 'Most likely.', 'Outlook good.', 'Yes.', 'Signs point to yes.', 'Reply hazy, try again.', 'Ask again later.', 'Better not tell you now.', 'Cannot predict now.', 'Concentrate and ask again.', "Don't count on it.", 'My reply is no.', 'My sources say no.', 'Outlook not so good.', 'Very doubtful.', 'Ya like jazz? I do!' ] self.hug_images = [ 'https://media.tenor.com/images/c5a29b75582f26c28f5d271384f673ad/tenor.gif', 'https://media.tenor.com/images/9164f10a0dbbf7cdb6aeb46184b16365/tenor.gif',
def __init__(self, bot): self.bot = bot self.faker = faker.Faker() self.srapi = sr_api.Client()
def __init__(self, **kwargs): super().__init__( command_prefix=get_prefix, case_insensitive=True, # case_insensitive_prefix=True, status=discord.Status.dnd, activity=discord.Activity(type=discord.ActivityType.competing, name='a boot up challenge'), owner_id=345457928972533773, reconnect=True, allowed_mentions=discord.AllowedMentions(users=False, roles=False, everyone=False, replied_user=True), max_messages=10000, chunk_guilds_at_startup=True, # this is here for easy access. In case I need to switch it fast to False I won't need to look at docs. intents=discord.Intents( guilds=True, # guild/channel join/remove/update members=True, # member join/remove/update bans=True, # member ban/unban emojis=False, # emoji update integrations=False, # integrations update webhooks=False, # webhook update invites=False, # invite create/delete voice_states=True, # voice state update presences=True, # member/user update for games/activities guild_messages=True, # message create/update/delete dm_messages=True, # message create/update/delete guild_reactions=True, # reaction add/remove/clear dm_reactions=True, # reaction add/remove/clear guild_typing=False, # on typing dm_typing=False, # on typing ) ) self.config = config for extension in config.EXTENSIONS: try: self.load_extension(extension) print(f'[EXTENSION] {extension} was loaded successfully!') except Exception as e: print(f'[WARNING] Could not load extension {extension}: {e}') self.db = kwargs.pop("db") self.cmdUsage = {} self.cmdUsers = {} self.guildUsage = {} self.process = psutil.Process() self.support = 'https://discord.gg/f3MaASW' self.invite = 'https://dredd-bot.xyz/invite' self.privacy = '<https://gist.github.com/TheMoksej/02671c21451843d8186e718065b731ee>' self.license = '<https://github.com/TheMoksej/Dredd/blob/master/LICENSE>' self.gif_pfp = 'https://cdn.discordapp.com/attachments/667077166789558288/747132112099868773/normal_3.gif' self.vote = '<https://discord.boats/bot/667117267405766696/vote>' self.source = '<https://github.com/TheMoksej/Dredd/>' self.statuspage = '<https://status.dredd-bot.xyz>' self.bot_lists = {'dbots': "[Discord Bot Labs](https://dbots.cc/dredd 'bots.discordlabs.org')", 'dboats': "[Discord Boats](https://discord.boats/bot/667117267405766696/vote 'discord.boats')", 'dbl': "[Discord Bot list](https://discord.ly/dredd/upvote 'discordbotlist.com')", 'shitgg': "[Top.GG](https://top.gg/bot/667117267405766696/vote 'top.gg')"} self.cleverbot = ac.Cleverbot(config.CB_TOKEN) self.join_counter = Counter() # counter for anti raid so the bot would ban the user if they try to join more than 5 times in short time span self.cache = CacheManager self.cmd_edits = {} self.dm = {} self.dms = {} # cache for checks if user was already informed about dm logging self.updates = {} self.snipes = {} self.sr_api = sr_api.Client() self.guilds_data = {} self.loop = asyncio.get_event_loop() self.guild_loop = {} self.to_dispatch = {} self.music_guilds = {} # ranks self.devs = {} self.admins = {} self.boosters = {} self.lockdown = False self.auto_reply = True self.settings = {} self.blacklist = {} self.check_duration = {} # guilds / moderation self.prefix = {} self.moderation = {} self.memberlog = {} self.joinlog = {} self.leavelog = {} self.guildlog = {} self.joinrole = {} self.joinmessage = {} self.leavemessage = {} self.messageedits = {} self.messagedeletes = {} self.antihoist = {} self.automod = {} self.massmention = {} self.masscaps = {} self.invites = {} self.links = {} self.spam = {} self.modlog = {} self.raidmode = {} self.temp_bans = {} self.temp_mutes = {} self.mute_role = {} self.mod_role = {} self.admin_role = {} self.channels_whitelist = {} self.roles_whitelist = {} self.guild_disabled = {} self.cog_disabled = {} self.case_num = {} self.rr = {} # other self.afk = {} self.status_op = {} self.snipes_op = {} self.nicks_op = {} self.badges = {} self.disabled_commands = {} self.translations = {} self.reminders = {}
def __init__(self, bot): self.bot = bot self.afapi = alexflipnote.Client(os.getenv('AF_TOKEN'), loop=self.bot.loop) self.srapi = sr_api.Client()
from discord.ext import commands from prsaw import RandomStuff import ka as ka restart_reason = "removed customizable prefixes again!" owners = [801234598334955530, 814226043924643880] prefix = "rap " rs = RandomStuff(async_mode=True) client = commands.Bot(command_prefix=prefix, intents=discord.Intents.all(), allowed_mentions=discord.AllowedMentions(roles=False, everyone=False), case_insensitive=True, owner_ids=owners) client.sr_api = sr_api.Client() client.launch_time = datetime.datetime.utcnow() client.warnings = {} bot = client client.bldb = aiosqlite.connect("db/bl.sqlite") smoother = True client.reaction_roles = [] client.load_extension('jishaku') note = "Note from owner:```fix\nworking on antiswearing.. -ks\n```" class bcolors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKCYAN = '\033[96m'
def __init__(self, bot): self.bot = bot self.client = aiozaneapi.Client(self.bot.config["zanekey"]) self.sr_client = sr_api.Client()
county_graph = os.path.join(config.botdir, 'plot-county.png') state_graph = os.path.join(config.botdir, 'plot-state.png') us_graph = os.path.join(config.botdir, 'plot-nation.png') # This code logs all events including chat to discord.log. This file will be overwritten when the bot is restarted - rename the file if you want to keep it. logger = logging.getLogger('discord') logger.setLevel(logging.DEBUG) handler = logging.FileHandler(filename=config.logfile, encoding='utf-8', mode='w') handler.setFormatter( logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) logger.addHandler(handler) #Define handler early to prevent overhead srapi = sr_api.Client() def get_prefix(client, message): if not message.guild: return commands.when_mentioned_or(config.pref)(client, message) with open('prefixes.json', 'r') as f: prefixes = json.load(f) if str(message.guild.id) not in prefixes: return commands.when_mentioned_or(config.pref)(client, message) prefix = prefixes[str(message.guild.id)] return commands.when_mentioned_or(prefix)(client, message) def file_age_in_seconds(pathname):