def get_text_ch_update_embed( cls, before: discord.TextChannel, after: discord.TextChannel) -> Optional[discord.Embed]: """Constructs the embed for the 'on_guild_channel_update' event for text channels.""" # log.info(f"Text channel Updated! {after.name} in {after.category}, Pos: {after.position}") embed = discord.Embed(title="Text Channel Updated", description=f"Update info for: <#{after.id}>", timestamp=datetime.utcnow(), color=discord.Color.blurple()) embed.set_footer(text=f"Channel ID: {after.id}") if before.name != after.name: embed.add_field( name="Name Changed:", value= f"{before_txt}**{before.name}**\n{now_txt}**{after.name}**") if before.category != after.category: embed.add_field( name="Category Changed", value= f"{before_txt}**{before.category}**\n{now_txt}**{after.category}**" ) if before.topic != after.topic: if not (before.topic is None and after.topic == ""): embed.add_field( name="Topic Changed:", value= f"{before_txt}**{before.topic}**\n{now_txt}**{after.topic}**" ) if before.slowmode_delay != after.slowmode_delay: before_delay = f"{before.slowmode_delay} Sec" if before.slowmode_delay > 0 else "Disabled" after_delay = f"{after.slowmode_delay} Sec" if after.slowmode_delay > 0 else "Disabled" embed.add_field( name="Slowmode Delay Changed:", value= f"{before_txt}**{before_delay}**\n{now_txt}**{after_delay}**") if before.is_nsfw() != after.is_nsfw(): before_nsfw = "Yes" if before.is_nsfw() else "No" after_nsfw = "Yes" if after.is_nsfw() else "No" embed.add_field( name="NSFW Status Changed:", value= f"{before_txt}**{before_nsfw}**\n{now_txt}**{after_nsfw}**") # if before.changed_roles != after.changed_roles: # embed.add_field(name="changed_roles Changed:", value=f"{now_txt}{after.changed_roles}\n{before_txt}{before.changed_roles}") if before.overwrites != after.overwrites: embed = cls.determine_changed_overrides(embed, before, after) return embed if len(embed.fields) > 0 else None
async def _perform_search(self, requester: str, channel: discord.TextChannel, subreddit: str, sort_by: str): """ Performs the search for queries with aiohttp. Returns 10 items. """ async with self.bot.session.get( f"https://reddit.com/r/{subreddit}/about.json", headers=self.headers) as subr_top_resp: subr_deets = await subr_top_resp.json() if "data" not in subr_deets: raise commands.BadArgument("Subreddit not found.") if subr_deets["data"].get("over18", None) and not channel.is_nsfw(): raise commands.NSFWChannelRequired(channel) params = {"t": "all" if sort_by == "top" else ""} async with self.bot.session.get( f"https://reddit.com/r/{subreddit}/{sort_by}.json", headers=self.headers, params=params, ) as subr_resp: subreddit_json = await subr_resp.json() subreddit_pages = [] common_img_exts = (".jpg", ".jpeg", ".png", ".gif") idx = 0 for post_data in subreddit_json["data"]["children"]: image_url = None video_url = None if idx == 20: break _short = post_data["data"] if _short.get("stickied", False) or (_short.get("over_18", False) and not channel.is_nsfw()): idx += 1 continue image_url = (_short["url"] if _short["url"].endswith(common_img_exts) else None) if "v.redd.it" in _short["url"]: image_url = _short["thumbnail"] video_teriary = _short.get("media", None) if video_teriary: video_url = _short["url"] else: continue subreddit_pages.append( SubredditPost(_short, image_link=image_url, video_link=video_url)) idx += 1 return self._gen_embeds(requester, subreddit_pages[:30])
async def snipe(self, ctx, channel: discord.TextChannel = None): if channel is None: channel = ctx.channel snop = await self.bot.pool.fetchrow( "SELECT * FROM del_snipe WHERE channel_id = $1 AND guild_id = $2", channel.id, ctx.guild.id, ) if snop is None: return await ctx.send("Nothing to snipe", delete_after=30) if channel.is_nsfw() is True and ctx.channel.is_nsfw() is False: return await ctx.send( "No sniping NSFW outside of NSFW channel.", delete_after=30 ) user = self.bot.get_user(snop["user_id"]) guild = self.bot.get_guild(snop["guild_id"]) chnl = discord.utils.get(guild.text_channels, id=snop["channel_id"]) del_time = datetime.now(timezone.utc) - snop["msg_time"] if snop["msg_type"] == 1: e = discord.Embed( colour=0x7289DA, description="The image may not be visible" ) e.set_author(name=f"{user.name} sent in {chnl.name}") e.set_image(url=snop["message"]) e.set_footer(text=f"sniped!") await ctx.send(embed=e) else: user = self.bot.get_user(snop["user_id"]) guild = self.bot.get_guild(snop["guild_id"]) chnl = discord.utils.get(guild.text_channels, id=snop["channel_id"]) e = discord.Embed(colour=0x7289DA, description=snop["message"]) e.set_author(name=f"{user.name} said in {chnl.name}") e.set_footer(text=f"sniped!") await ctx.send(embed=e)
async def tekstkanal(self, ctx, *, kanal: discord.TextChannel): """Viser info om en tekstkanal""" nsfw = 'Nei' if kanal.is_nsfw(): nsfw = 'Ja' if kanal.slowmode_delay == 0: saktemodus = 'Nei' else: saktemodus = f'Ja ({kanal.slowmode_delay} sekunder)' description = '**Ingen**' if kanal.topic: description = kanal.topic members = [] for member in kanal.members: members.append(member.mention) members = ' '.join(members) if len(members) > 1024: members = 'For mange for å vise her' embed = discord.Embed(color=ctx.me.color, description=f'{kanal.mention}\nID: {kanal.id}') embed.set_author(name=kanal.guild.name, icon_url=kanal.guild.icon_url) embed.add_field(name='Beskrivelse', value=description, inline=False) embed.add_field(name='Opprettet', value=kanal.created_at.strftime('%d %b %Y %H:%M')) embed.add_field(name='NSFW', value=nsfw) embed.add_field(name='Saktemodus', value=saktemodus) if kanal.category: embed.add_field(name='Kategori', value=kanal.category.name) embed.add_field(name=f'Antall med tilgang ({len(kanal.members)})', value=members) await Defaults.set_footer(ctx, embed) await ctx.send(embed=embed)
async def scramble(self, ctx, channel: discord.TextChannel = None, *members: discord.Member): """Generates a message based on the last 1000 messages in a specified channel (or the current one if none was given). """ channel = channel or ctx.channel if channel.is_nsfw() and not ctx.channel.is_nsfw(): return await ctx.send("Cannot post nsfw content in non-nsfw channels.") async with ctx.typing(): if not members: msgs = [m.clean_content async for m in channel.history(limit=1000)] else: msgs = [] c = 0 async for m in channel.history(limit=None): if m.author not in members: continue msgs.append(m.clean_content) c += 1 if c == 1000: break msg = await self.bot.loop.run_in_executor(None, self.generate_message, " ".join(msgs)) if len(msg) >= 2000: await ctx.send("Result was too large! Posting a part of it.") msg = msg[:2000] await ctx.send(msg)
async def snipe(self, ctx, channel: discord.TextChannel = None): """ Get the most recent deleted message You can pass in the channel mention/name/id so it'd fetch message in that channel """ channel = channel or ctx.channel check = cm.get_cache(self.bot, channel.id, 'snipes') if check is None: return await ctx.send( f"{emotes.red_mark} Haven't logged anything yet") if check['nsfw'] and not channel.is_nsfw(): return await ctx.send( f"{emotes.other_nsfw} This channel needs to be NSFW in order for you to see the sniped content" ) content = check['message'] if len(content) > 2000: content = content[:2000] content += '...' content = content or "*[Content unavailable]*" e = discord.Embed(color=self.color['embed_color']) a = ctx.guild.get_member(check['author']) if a is None: return await ctx.send(f"{emotes.warning} Couldn't get that member." ) e.set_author(name=f"Deleted by {a}", icon_url=a.avatar_url) e.description = f"{content}" e.set_footer( text= f"Deleted {btime.human_timedelta(check['deleted_at'])} in #{channel.name}" ) await ctx.send(embed=e)
async def snipe(self, ctx, index: int = 1, channel: discord.TextChannel = None): if channel and channel.is_nsfw(): return await qembed(ctx, 'no sorry') if not channel: channel = ctx.channel try: msg = self.deleted_message_for(index - 1, channel.id) try: await ctx.send(embed=msg.del_embed) content = 'Bot deleted an embed which was sent above.' if not msg.content else msg.content except AttributeError: content = msg.content except IndexError: return await qembed(ctx, 'Nothing to snipe!') snipe = discord.Embed(title='Content:', description=content, color=self.bot.embed_color, timestamp=ctx.message.created_at) if msg.attachment: snipe.add_field(name='Attachment', value=msg.attachment, inline=False) snipe.add_field(name='Message Stats:', value= f"**Created At:** {humanize.naturaldelta(msg.created_at - datetime.datetime.utcnow())} ago\n" f"**Deleted At:** {humanize.naturaldelta(msg.deleted_at - datetime.datetime.utcnow())} ago\n" f"**Index:** {index} / {len(self.bot.deleted_messages[channel.id])}", inline=False) snipe.set_author(name=f'{str(msg.author)} said in #{channel.name}:', icon_url=str(msg.author.avatar_url)) snipe.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=snipe)
async def snipe(self, ctx, channel: discord.TextChannel = None, index: int = 0): channel = channel or ctx.channel if index != 0: index = index - 1 if channel.is_nsfw(): return await ctx.send( ":warning: | **Attempting to snipe a NSFW channel**", delete_after=5 ) try: sniped = self.snipes[channel.id][index] except BaseException: return await ctx.send( ":warning: | **No message to snipe or index must not be greater than 5 or lower than 1**", delete_after=10, ) embed = discord.Embed( color=rint(0x000000, 0xFFFFFF), timestamp=sniped.created_at, title=f"@{sniped.author} said in #{sniped.channel}", description=sniped.clean_content, ) embed.set_footer( text=f"Sniped by {ctx.author.name} | Message created", icon_url=ctx.author.avatar_url, ) embed.set_thumbnail(url=sniped.author.avatar_url) await ctx.send(embed=embed)
async def show_snipes(self, ctx, amount: int = 5, channel: discord.TextChannel = None): """ Select the last N snipes from this channel. """ if channel: if not ctx.author.guild_permissions.manage_messages: return await ctx.send( "Sorry, you need to have 'Manage Messages' to view another channel." ) if channel.is_nsfw() and not ctx.channel.is_nsfw(): return await ctx.send( "No peeping NSFW stuff in here you dirty boi/gurl.") channel = channel or ctx.channel query = "SELECT * FROM snipe_deletes WHERE guild_id = $2 AND channel_id = $3 ORDER BY id DESC LIMIT $1;" results = await self.bot.pool.fetch(query, amount, ctx.guild.id, channel.id) dict_results = [dict(result) for result in results] if results else [] local_snipes = [ snipe for snipe in self.snipe_deletes if snipe["channel_id"] == channel.id ] full_results = dict_results + local_snipes if not full_results: return await ctx.send("No snipes for this channel.") full_results = sorted(full_results, key=lambda d: d["delete_time"], reverse=True)[:amount] embeds = self._gen_delete_embeds(full_results) pages = RoboPages( source=SnipePageSource(range(0, len(embeds)), embeds), delete_message_after=True, ) await pages.start(ctx)
async def autolooder(self, ctx, channel: discord.TextChannel): """Enable/Disable the autolooder for your server, mention an already added channel to disable.""" if not await self.has_donated(ctx.author.id): return await ctx.send( "You have not donated <a:rainbowNekoDance:462373594555613214>") async with self.bot.sql_conn.acquire() as conn: async with conn.cursor() as db: if await db.execute( "SELECT 1 FROM autolooder WHERE channel = %s", (channel.id, )): await db.execute( "DELETE FROM autolooder WHERE channel = %s", (channel.id)) return await ctx.send("Disabled autolooder from `%s`" % channel.name) if channel.is_nsfw(): await db.execute("INSERT INTO autolooder VALUES (%s)", (channel.id, )) await ctx.send("Enabled autolooder for `%s`" % (channel.name, )) else: return await ctx.send( "That channel is not an NSFW channel.")
async def channel(self, ctx, *, channel: discord.TextChannel = None): channel = ctx.channel if not channel else channel embed = discord.Embed(title=f"關於頻道內容", colour=random.randint(0, 0xffffff), timestamp=datetime.datetime.utcnow()) embed.add_field(name="📛頻道名稱", value=channel.name, inline=True) embed.add_field(name="🆔️頻道ID", value=channel.id, inline=True) embed.add_field( name="📁頻道類別", value= f"{'{}'.format(channel.category.name) if channel.category else '這個頻道不在任何類別內'}", inline=True) embed.add_field(name="🌏頻道位置", value=channel.position, inline=True) embed.add_field( name="🔸️頻道主題", value=f"{channel.topic if channel.topic else '此頻道沒有主題'}", inline=True) embed.add_field(name="⏱頻道慢數時間", value=channel.slowmode_delay, inline=True) embed.add_field(name="🔞NSFW", value=channel.is_nsfw(), inline=True) embed.add_field(name="📣NEWS", value=channel.is_news(), inline=True) embed.add_field( name="🕒頻道創建時間", value=channel.created_at.__format__("%Y/%m/%d %H:%M:%S"), inline=True) embed.add_field(name="Channel Permissions Synced", value=channel.permissions_synced, inline=True) embed.add_field(name="Channel Hash", value=hash(channel), inline=True) await ctx.send(embed=embed)
async def _list(self, ctx, channel: discord.TextChannel = None): """List deleted/edited messages for a channel""" if not channel: channel = ctx.channel if ctx.channel.is_nsfw() is False and channel.is_nsfw() is True: return await ctx.send("You cannot snipe a nsfw channel from a non-nsfw channel") if not channel.id in self.snipe_dict: return await ctx.send("This channel has no recorded messages") pager = paginator(self.bot) e = discord.Embed(color=discord.Color.blurple()) Set = 1 for msg in self.snipe_dict[channel.id]: if len(e.fields) >= 5: e.set_footer(text=f"{Set*5-4}-{Set*5}/{len(self.snipe_dict[channel.id])-1}") Set += 1 pager.add_page(data=e) e = discord.Embed(color=discord.Color.blurple()) else: e.add_field( name=f"**{msg.author.display_name}** said in **#{msg.channel.name}**", value=msg.content[:100], inline=False ) e.set_footer(text=f"{Set*5-4}-{Set*5}/{len(self.snipe_dict[channel.id])-1}") pager.add_page(data=e) await pager.do_paginator(ctx)
async def channelinfo(self, ctx, *, channel: discord.TextChannel = None): """Display information about a text channel. Defaults to the current channel. * channel - Optional argument. A specific channel to get information about.""" # If channel is None, then it is set to ctx.channel. channel = channel or ctx.channel embed = discord.Embed(title=f"{channel.name}") try: embed.description = channel.topic except AttributeError: pass embed.add_field(name="Channel ID", value=channel.id) try: embed.add_field(name="Guild", value=channel.guild.name) except AttributeError: pass embed.add_field(name="Members", value=len(channel.members)) embed.add_field(name="Created at", value=channel.created_at.ctime()) if channel.is_nsfw(): embed.set_footer(text="NSFW content is allowed for this channel.") await ctx.send(embed=embed)
def conv_text_channel_obj(channel: discord.TextChannel, export_role_overrides=True, export_user_overrides=True): logging.info( f"Dumping text channel '{channel.name}' in '{channel.guild.name}'") res = {} res["name"] = channel.name res["slowmode"] = channel.slowmode_delay res["nsfw"] = channel.is_nsfw() res["topic"] = channel.topic res["id"] = str(channel.id) perms = get_permission_overrides(channel) if export_role_overrides: logging.info( f"Dumping role permission overrides for text channel '{channel.name}' in '{channel.guild.name}'" ) res["role_permission_overrides"] = perms["roles"] if export_user_overrides: logging.info( f"Dumping user permission overrides for text channel '{channel.name}' in '{channel.guild.name}'" ) res["user_permission_overrides"] = perms["users"] return res
async def channelinfo(self, ctx, *, channel: discord.TextChannel = None): """Display information about a text channel.""" # If channel is None, then it is set to ctx.channel. channel = channel or ctx.channel embed = discord.Embed(title=f"{channel.name}", color=0xB388FF) try: embed.description = channel.topic except AttributeError: pass embed.add_field(name="Channel ID", value=channel.id, inline=False) try: embed.add_field(name="Guild", value=channel.guild.name, inline=False) except AttributeError: pass embed.add_field(name="Members", value=len(channel.members), inline=False) embed.add_field(name="Created at", value=channel.created_at.ctime(), inline=False) if channel.is_nsfw(): embed.set_footer(text="NSFW content is allowed for this channel.") embed.set_footer(text=f"Requested by {ctx.author.name}", icon_url=ctx.author.avatar_url_as(format="png")) await ctx.send(embed=embed)
def check_channel(self, bot: Red, channel: discord.TextChannel) -> bool: """ Checks if the channel is allowed to track starboard messages Parameters ---------- bot: Red The bot object channel: discord.TextChannel The channel we want to verify we're allowed to post in Returns ------- bool Whether or not the channel we got a "star" in we're allowed to repost. """ guild = bot.get_guild(self.guild) if channel.is_nsfw() and not guild.get_channel(self.channel).is_nsfw(): return False if self.whitelist: if channel.id in self.whitelist: return True if channel.category_id and channel.category_id in self.whitelist: return True return False else: if channel.id in self.blacklist: return False if channel.category_id and channel.category_id in self.blacklist: return False return True
async def channelinfo(self, ctx, channel: discord.TextChannel = None): """Shows info on a channel.""" async with ctx.typing(): channel = channel or ctx.channel td = { True: "<:nsfw:730852009032286288>", False: "<:text_channel:703726554018086912>", } if channel.overwrites_for( ctx.guild.default_role).read_messages is False: url = "<:text_locked:730929388832686090>" else: if channel.is_news(): url = "<:news:730866149109137520>" else: url = td[channel.is_nsfw()] embed = discord.Embed(colour=self.bot.colour) embed.title = f"{url} {channel.name} | {channel.id}" last_message = await channel.fetch_message(channel.last_message_id) pins = await channel.pins() embed.description = ( f"{channel.topic or ''}\n{f'<:category:716057680548200468> **{channel.category}**' if channel.category else ''} " f"<:member:731190477927219231> **{len(channel.members):,}** " f"{f'<:pin:735989723591344208> **{len(pins)}**' if pins else ''} <:msg:735993207317594215> [Last Message]({last_message.jump_url})" ) embed.description = f"{channel.topic or ''}\n{f'<:category:716057680548200468> **{channel.category}**' if channel.category else ''} <:member:731190477927219231> **{len(channel.members):,}** {f'<:pin:735989723591344208> **{len([*await channel.pins()])}**' if await channel.pins() else ''} <:msg:735993207317594215> [Last Message]({last_message.jump_url})" embed.set_footer( text=f'Channel created {nt(dt.utcnow() - channel.created_at)}') await ctx.send(embed=embed)
def get_snipes( self, command_author: discord.Member, command_channel: discord.TextChannel, *, channel: discord.TextChannel = None, guild: bool = False, authors: typing.List[discord.Member] = None, before: int = None, after: int = None, mode: SnipeMode = None, contains: str = None, ): if channel is None and guild is None: raise ValueError("Channel and Guild cannot both be None.") filters = [ lambda snipe: snipe.channel.permissions_for(command_author). read_messages ] if not command_channel.is_nsfw(): filters.append(lambda snipe: not snipe.channel.is_nsfw()) if authors: author_ids = [a.id for a in authors] filters.append(lambda snipe: snipe.author.id in author_ids) if before: filters.append(lambda snipe: snipe.id < before) if after: filters.append(lambda snipe: snipe.id > after) if mode: filters.append(lambda snipe: snipe.mode == mode) if contains: to_match = " ".join(contains) filters.append(lambda snipe: to_match in snipe.content) if guild: snipes = [] snipe_channels = self.bot.snipes[channel.guild.id] for channel_snipes in snipe_channels.values(): filtered = channel_snipes for _filter in filters: filtered = list(filter(_filter, filtered)) snipes.extend(filtered) # need to be reordered by time, would be by channel otherwise snipes = list(reversed(sorted(snipes, key=lambda s: s.time))) else: snipes = self.bot.snipes[channel.guild.id][channel.id] for _filter in filters: snipes = list(filter(_filter, snipes)) return snipes
def __init__(self, channel: discord.TextChannel): self._chn = channel self.guild = SafeAccessGuild(channel.guild) if channel.guild else VP_NONE self.id = channel.id self.nsfw = channel.is_nsfw() self.news = channel.is_news() self.topic = channel.topic self.mention = channel.mention
async def channel(self, ctx, chid: discord.TextChannel): if chid.is_nsfw() and not ctx.channel.is_nsfw(): em = discord.Embed(color=discord.Color.dark_teal()) em.add_field(name="NSFW Channel Required", value="You cannot snipe an NSFW channel from a non NSFW channel.") await ctx.send(embed=em) return data = await self.bot.pool.fetchrow(f"SELECT * FROM snipe WHERE guild = $1 AND channel = $2 {self.ta}", ctx.guild.id, chid.id) await self.data(ctx, data)
async def _nsfw(self, ctx, channel: discord.TextChannel=None): if channel is None: channel = ctx.message.channel if channel.is_nsfw(): await channel.edit(nsfw=False) return await ctx.send(embed=discord.Embed(color=0xDEADBF, description=f"{i_nsfw} Eu desativei o nsfw deste canal.")) await channel.edit(nsfw=True) await ctx.send(embed=discord.Embed(color=0xDEADBF, description=f"{i_nsfw} Eu ativei o nsfw deste canal."))
async def textchannel(self, ctx: commands.Context, channel: discord.TextChannel): """Shows information about a text channel""" embed = discord.Embed(title='#' + channel.name, description=channel.topic) \ .add_field(name='ID', value=channel.id) \ .add_field(name='Created at', value=channel.created_at.strftime('%d.%m.%Y %H:%M')) if channel.is_nsfw(): embed.add_field(name='NSFW', value='This channel is NSFW') msg = await ctx.send(embed=embed) await utils.wait_to_delete(self.bot, ctx.message, msg)
def __init__(self, runner, channel: discord.TextChannel): self._chn = channel self._runner = runner self.guild = SafeAccessGuild( runner, channel.guild) if channel.guild else runner.null self.id = viper.Integer(channel.id, -1, runner) self.nsfw = viper.Boolean(channel.is_nsfw(), -1, runner) self.news = viper.Boolean(channel.is_news(), -1, runner) self.topic = viper.String(channel.topic, -1, runner) self.mention = viper.String(channel.mention, -1, runner)
async def nsfwchannel(self, ctx: commands.Context, channel: discord.TextChannel = None): if channel is None: await self.config.guild(ctx.guild).channel_id.set(None) await ctx.send("NSFW Channel cleared") else: if not channel.is_nsfw(): await ctx.send("This channel isn't NSFW!") return else: await self.config.guild(ctx.guild).channel_id.set(channel.id) await ctx.send("NSFW channel has been set to {}".format(channel.mention))
async def channelinfo(self, ctx, channel: discord.TextChannel = None): if channel is None: channel = ctx.message.channel embed = discord.Embed(color=orange, description=channel.mention) embed.add_field(name="Name", value=channel.name) embed.add_field(name="Server", value=channel.guild) embed.add_field(name="ID", value=channel.id) embed.add_field(name="Category ID", value=channel.category_id) embed.add_field(name="Position", value=channel.position) embed.add_field(name="NSFW", value=str(channel.is_nsfw())) embed.add_field(name="Members (cached)", value=str(len(channel.members))) embed.add_field(name="Category", value=channel.category) embed.add_field(name="Created", value=channel.created_at.strftime("%d %b %Y %H:%M")) embed.set_footer(text=f"Command used by: {ctx.author.name}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed)
async def scramble(self, ctx, channel: discord.TextChannel = None): """Generates a message based on the last 1000 messages in a specified channel (or the current one if none was given). """ channel = channel or ctx.channel if channel.is_nsfw() and not ctx.channel.is_nsfw(): return await ctx.send("Cannot post nsfw content in non-nsfw channels.") async with ctx.typing(): msgs = [m.clean_content async for m in channel.history(limit=1000) if not m.author.bot] if not msgs: return await ctx.send("Couldn't fetch any messages from " + channel.mention) msg = await self.bot.loop.run_in_executor(None, self.generate_message, " ".join(msgs)) if len(msg) >= 2000: await ctx.send("Result was too large! Posting a part of it.") msg = msg[:2000] await ctx.send(msg)
async def channelinfo(self, ctx, channel: discord.TextChannel = None): if not channel: channel = ctx.channel embed = discord.Embed(colour=discord.Colour.gold()) embed.add_field(name="Channel Name", value=channel.name) embed.add_field(name="ID", value=channel.id) embed.add_field(name="Type", value=channel.type) embed.add_field(name="Created", value=channel.created_at) embed.add_field(name="Topic", value=channel.topic) embed.add_field(name='Nswf', value=channel.is_nsfw()) embed.set_footer(text=f"YumeBot", icon_url=self.bot.user.avatar_url) await ctx.send(embed=embed)
async def nsfw(self, ctx, channel:discord.TextChannel = None): """Make a channel NSFW.""" if channel is None: channel = ctx.message.channel try: if channel.is_nsfw(): await channel.edit(nsfw=False) await ctx.send(f"I have removed NSFW permissions from {channel.name}") else: await channel.edit(nsfw=True) await ctx.send(f"I have have made {channel.name} an NSFW channel for you <3") except: try: await ctx.send("I can't make that channel NSFW or don't have permissions to ;c") except: pass
async def snipe(self, ctx, *, channel: discord.TextChannel = None): """Snipe a deleted message""" channel = channel or ctx.channel sniped = await ctx.bot.db.execute( "SELECT * FROM snipes WHERE channel_id == ? AND guild_id == ?;", (channel.id, ctx.guild.id) ) fetched = await sniped.fetchone() if not fetched: return await ctx.send("Nothing to snipe... yet.") if channel.is_nsfw() is True and ctx.channel.is_nsfw() is False: return await ctx.send("You cannot snipe from a normal channel into an NSFW one.") user_perms = ctx.author.permissions_in(channel) if not user_perms.read_messages or not user_perms.read_message_history: return await ctx.send(":x: You cannot see that channel.") desc = [c_name[0] for c_name in sniped.description] guild = ctx.bot.get_guild(fetched[desc.index("guild_id")]) if guild is None: return await ctx.send(":x: Unable to fetch some data.") user = ctx.bot.get_user(fetched[desc.index("user_id")]) if not user: user = await ctx.bot.fetch_user(fetched[desc.index("user_id")]) if user is None: return await ctx.send(":x: Unable to fetch some data.") chnl = discord.utils.get(guild.text_channels, id=fetched[desc.index("channel_id")]) if chnl is None: return await ctx.send(":x: Unable to fetch some data.") message_id = fetched[desc.index("message_id")] msg_content = fetched[desc.index("message")] e = ctx.default_embed() if fetched[desc.index("msg_type")] == 1: e.description = "The image may not be visible" e.set_author(name=f"{user.name} sent in {chnl.name}") e.set_image(url=msg_content) elif fetched[desc.index("msg_type")] == 2: e.set_author(name=f"{user.name} said in an embed in #{chnl.name}:") e.description = msg_content else: e.description = msg_content e.set_author(name=f"{user.name} said in #{chnl.name}") e.set_footer(text=f"Message ID {message_id} | User ID {user.id} | Channel ID {chnl.id} | Guild ID {guild.id}") await ctx.send(embed=e)
async def channelinfo(self, ctx, channel: discord.TextChannel = None): """Get Channel Info""" if channel is None: channel = ctx.message.channel embed = discord.Embed(color=0xDEADBF, description=channel.mention) embed.add_field(name="Name", value=channel.name) embed.add_field(name="Guild", value=channel.guild) embed.add_field(name="ID", value=channel.id) embed.add_field(name="Category ID", value=channel.category_id) embed.add_field(name="Position", value=channel.position) embed.add_field(name="NSFW", value=str(channel.is_nsfw())) embed.add_field(name="Members", value=len(channel.members)) embed.add_field(name="Category", value=channel.category) embed.add_field(name="Created at", value=channel.created_at.strftime("%d %b %Y %H:%M")) await ctx.send(embed=embed)