def poke_color(color):
return {
"black": discord.Color(0x000000),
"blue": discord.Color.blue(),
"brown": discord.Color(0xD2691E),
"gray": discord.Color(0xA9A9A9),
"green": discord.Color.green(),
"pink": discord.Color(0xFF69B4),
"purple": discord.Color.purple(),
"red": discord.Color.red(),
"white": discord.Color(0xFFFFFF),
"yellow": discord.Color(0xFFFF00)
}[color]
python类Color()的实例源码
def neko(self, ctx):
"""Posts a random neko picture."""
api_url = 'http://nekos.life/api/neko'
response = await self.get_json(api_url)
image_url = response['neko']
embed = discord.Embed(color=discord.Color(0xf84a6e))
embed.set_image(url=image_url)
await ctx.send(embed=embed)
def simple_embed(self, text, title="", color=discord.Color.default()):
embed = discord.Embed(title=title, color=color)
embed.description = text
await self.bot.say("", embed=embed)
def soundhax(self):
"""Links to Soundhax Website"""
embed = discord.Embed(title="Soundhax", color=discord.Color.blue())
embed.set_author(name="Ned Williamson", url="http://soundhax.com/")
embed.set_thumbnail(url="http://i.imgur.com/lYf0jan.png")
embed.url = "http://soundhax.com"
embed.description = "Free 3DS Primary Entrypoint <= 11.3"
await self.bot.say("", embed=embed)
# dsp dumper command
def dsp(self):
"""Links to Dsp1."""
embed = discord.Embed(title="Dsp1", color=discord.Color.green())
embed.set_author(name="zoogie", url="https://github.com/zoogie", icon_url="https://gbatemp.net/data/avatars/l/357/357147.jpg?1426471484")
embed.description = "Dump 3DS's DSP component to SD for homebrew audio."
embed.set_thumbnail(url="https://raw.githubusercontent.com/Cruel/DspDump/master/icon.png")
embed.url = "https://github.com/zoogie/DSP1/releases"
await self.bot.say("", embed=embed)
def updateb9s(self):
"""Links to the guide for updating b9s versions"""
embed = discord.Embed(title="Updating B9S Guide", color=discord.Color(0xCE181E))
embed.set_author(name="Plailect", url="https://3ds.guide/updating-b9s")
embed.set_thumbnail(url="https://3ds.guide/images/bio-photo.png")
embed.url = "https://3ds.guide/updating-b9s"
embed.description = "A guide for updating to new B9S versions."
await self.bot.say("", embed=embed)
def atob(self):
"""Links to the guide for updating from a9lh to b9s"""
embed = discord.Embed(title="Upgrading a9lh to b9s", color=discord.Color(0xCE181E))
embed.set_author(name="Plailect", url="https://3ds.guide/a9lh-to-b9s")
embed.set_thumbnail(url="https://3ds.guide/images/bio-photo.png")
embed.url = "https://3ds.guide/a9lh-to-b9s"
embed.description = "A guide for upgrading your device from arm9loaderhax to boot9strap."
await self.bot.say("", embed=embed)
# Gateway h&s troubleshooting command
def ctr(self):
"""Links to ctrtransfer guide"""
embed = discord.Embed(title="Guide - ctrtransfer", color=discord.Color.orange())
embed.set_author(name="Plailect", url="https://3ds.guide/")
embed.set_thumbnail(url="https://3ds.guide/images/bio-photo.png")
embed.url = "https://3ds.guide/ctrtransfer"
embed.description = "How to do the 11.5.0-38 ctrtransfer"
await self.bot.say("", embed=embed)
def brick(self):
"""Warns about 2.1 dangers"""
await self.simple_embed("While on 2.1, **NEVER** shut the N3DS lid, update any model, format a 2DS or attempt to play a game on a cartridge. Doing any of these things *will* brick your system.", color=discord.Color.red())
def vguides(self):
"""Information about video guides relating to custom firmware"""
embed = discord.Embed(title="Why you should not use video guides", color=discord.Color.dark_orange())
embed.description = "\"Video guides\" for custom firmware and arm9loaderhax/boot9strap are not recommended for use. Their contents generally become outdated very quickly for them to be of any use, and they are harder to update unlike a written guide.\n\nWhen this happens, video guides become more complicated than current methods, having users do certain tasks which may not be required anymore.\n\nThere is also a risk of the uploader spreading misinformation or including potentially harmful files, sometimes unintentionally. Using other people's files to install arm9loaderhax can cause serious issues and even brick your system."
embed.add_field(name="Recommended", value="The recommended thing to do is to use [Plailect's written complete guide for boot9strap](https://3ds.guide). It is the most up to date one and is recommended for everyone.")
await self.bot.say("", embed=embed)
def stock114(self):
"""Advisory for consoles on stock 11.4+ firmware"""
embed = discord.Embed(title="Running stock (unmodified) 11.4+ firmware?", color=discord.Color.dark_orange())
embed.description = "You have 3 possible options for installing CFW:\n- [NTRBoot](https://3ds.guide/ntrboot) which needs a compatible DS flashcart and maybe an additional hacked 3DS or DS(i) console depending on the flashcart\n- [DSiWare](https://3ds.guide/installing-boot9strap-\(dsiware\)) which involves system transferring from a hacked 3DS to an unhacked 3DS\n- [Hardmod](https://3ds.guide/installing-boot9strap-\(hardmod\)) which requires soldering **Not for beginners!**\n **Downgrading is impossible on 11.4+!**"
await self.bot.say("", embed=embed)
def failedupdate(self):
"""Notice about failed update on Wii U"""
await self.simple_embed("A failed update in Download Management does not mean there is an update and the system is trying to download it. This means your blocking method (DNS etc.) is working and the system can't check for an update.", color=discord.Color(0x009AC7))
def emptysd(self):
"""What to do if you delete all your SD card contents"""
await self.simple_embed("If you have lost the contents of your SD card with CFW, you will need in SD root:\n-Homebrew launcher executable [here](https://smealum.github.io/ninjhax2/boot.3dsx)\n-`boot.firm` from [luma3ds latest release 7z](https://github.com/AuroraWright/Luma3DS/releases/latest)\nThen repeat the [finalizing setup](https://3ds.guide/finalizing-setup) page.", color=discord.Color.red())
# Embed to broken TWL Troubleshooting
def twl(self):
"""Information on how to fix a broken TWL Partition"""
embed = discord.Embed(title="Fix broken TWL", color=discord.Color(0xA2BAE0))
embed.set_author(name="Plailect", url="https://3ds.guide/troubleshooting#dsi--ds-functionality-is-broken-after-completing-the-guide")
embed.set_thumbnail(url="https://3ds.guide/images/bio-photo.png")
embed.url = "https://3ds.guide/troubleshooting#dsi--ds-functionality-is-broken-after-completing-the-guide"
embed.description = "Instructions on how to fix a broken TWL after doing the guide"
await self.bot.say("", embed=embed)
def gm9(self):
"""Links to the guide on GodMode9"""
embed = discord.Embed(title="GodMode9 Usage", color=discord.Color(0x66FFFF))
embed.set_author(name="Plailect", url="https://3ds.guide/godmode9-usage")
embed.set_thumbnail(url="https://3ds.guide/images/bio-photo.png")
embed.url = "https://3ds.guide/godmode9-usage"
embed.description = "GodMode9 usage guide"
await self.bot.say("", embed=embed)
def dump(self):
"""How to dump/build CIAs using GodMode9"""
embed = discord.Embed(title="GodMode9 dump/build Guide", color=discord.Color(0x66FFFF))
embed.set_author(name="ih8ih8sn0w", url="https://pastebin.com/sx8HYULr")
embed.set_thumbnail(url="http://i.imgur.com/QEUfyrp.png")
embed.url = "https://pastebin.com/sx8HYULr"
embed.description = "How to dump/build CIAs using GodMode9"
await self.bot.say("", embed=embed)
# Embed to ih8ih8sn0w's layeredfs guide
def layeredfs(self):
"""How to use Luma 8.0+ LayeredFs"""
embed = discord.Embed(title="LayeredFs Guide", color=discord.Color(0x66FFFF))
embed.set_author(name="ih8ih8sn0w", url="https://pastebin.com/sx8HYULr")
embed.set_thumbnail(url="http://i.imgur.com/QEUfyrp.png")
embed.url = "https://pastebin.com/QdzBv4Te"
embed.description = "How to use Luma 8.0+ LayeredFs for ROM Hacking."
await self.bot.say("", embed=embed)
# Information about sighax
def sighax(self):
"""Information about sighax"""
embed = discord.Embed(title="Sighax Information", color=discord.Color(0x0000ff))
embed.set_author(name="SciresM", url="https://www.reddit.com/r/3dshacks/comments/67f6as/psa_clearing_up_some_misconceptions_about_sighax/")
embed.set_thumbnail(url="https://i.imgur.com/11ajkdJ.jpg")
embed.url = "https://www.reddit.com/r/3dshacks/comments/67f6as/psa_clearing_up_some_misconceptions_about_sighax/"
embed.description = "PSA About Sighax"
await self.bot.say("", embed=embed)
def p7zip(self):
"""Download 7zip"""
embed = discord.Embed(title="Download 7zip", color=discord.Color(0x0000ff))
embed.set_thumbnail(url="http://i.imgur.com/cX1fuf6.png")
embed.url = "http://www.7-zip.org/download.html"
embed.description = "To be able to extract .7z files you need 7zip installed, get it here."
await self.bot.say("", embed=embed)
def user_spam_check(self, message):
if message.author.id not in self.user_antispam:
self.user_antispam[message.author.id] = []
self.user_antispam[message.author.id].append(message)
if len(self.user_antispam[message.author.id]) == 6: # it can trigger it multiple times if I use >. it can't skip to a number so this should work
await self.bot.add_roles(message.author, self.bot.muted_role)
await self.add_restriction(message.author, "Muted")
msg_user = "You were automatically muted for sending too many messages in a short period of time!\n\nIf you believe this was done in error, send a direct message to one of the staff in {}.".format(self.bot.welcome_channel.mention)
try:
await self.bot.send_message(message.author, msg_user)
except discord.errors.Forbidden:
pass # don't fail in case user has DMs disabled for this server, or blocked the bot
log_msg = "?? **Auto-muted**: {} muted for spamming | {}#{}\n?? __Creation__: {}\n?? __User ID__: {}".format(message.author.mention, message.author.name, message.author.discriminator, message.author.created_at, message.author.id)
embed = discord.Embed(title="Deleted messages", color=discord.Color.gold())
msgs_to_delete = self.user_antispam[message.author.id][:] # clone list so nothing is removed while going through it
for msg in msgs_to_delete:
embed.add_field(name="#"+msg.channel.name, value="\u200b" + msg.content) # added zero-width char to prevent an error with an empty string (lazy workaround)
await self.bot.send_message(self.bot.modlogs_channel, log_msg, embed=embed)
await self.bot.send_message(self.bot.mods_channel, log_msg + "\nSee {} for a list of deleted messages.".format(self.bot.modlogs_channel.mention))
for msg in msgs_to_delete:
try:
await self.bot.delete_message(msg)
except discord.errors.NotFound:
pass # don't fail if the message doesn't exist
await asyncio.sleep(3)
self.user_antispam[message.author.id].remove(message)
try:
if len(self.user_antispam[message.author.id]) == 0:
self.user_antispam.pop(message.author.id)
except KeyError:
pass # if the array doesn't exist, don't raise an error