Instantly share code, notes, and snippets.

Embed
What would you like to do?
ShugaBot OSS Edition
# S H U G A B O T / / /
# Created by HeyItsShuga
#
# This is the open-source version of ShugaBot.
# It is different from the version you can add
# at https://shuga.co/discord/add, only
# including the most interesting features.
# To implement, use Red-DiscordBot and put this
# file in the cogs/ folder as "shuga.py". This
# will add the ShugaBot OSS commands into your
# Red-DiscordBot instance. If you are interested
# in contributing to ShugaBot please message me
# on Twitter (@HeyItsShuga) or Reddit
# (/u/HeyItsShuga) and I might add it to the
# release version.
#
# Link to Red-DiscordBot (required):
# https://github.com/Twentysix26/Red-DiscordBot
#
# LICENSE: This license abides by the rules of
# GPL-V2. However, you are not permitted to use
# or distribue this project with the intent of
# financial gain, nullifying the relevant
# clauses (dealing with financial gain and
# commercialization) in the GPL-V2 license.
import discord
from discord.ext import commands
class Core:
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True, no_pm=True)
async def about(self, ctx):
"""Versioning info"""
#Your code will go here
channel = ctx.message.channel
em = discord.Embed(title="About", description="**Version:** 0.1.0\n**Creator:** HeyItsShuga\n*Flavor:** Open-Source\n**Special Thanks:** iGummie, Twentysix26", colour=0x111111)
em.set_author(name="ShugaBot", icon_url="https://i.imgur.com/07WBSqf.png")
await self.bot.send_message(channel, embed=em)
@commands.command(pass_context=True, no_pm=True)
async def cat(self, ctx):
"""Get a picture of a cat."""
#Your code will go here
import urllib.request
urllib.request.urlretrieve ("http://thecatapi.com/api/images/get?format=src&type=jpg", "cat.jpg")
await self.bot.send_file(ctx.message.channel, 'cat.jpg')
@commands.command(pass_context=True, no_pm=True)
async def afk(self, ctx):
"""GO AFK."""
#Your code will go here
channel = ctx.message.channel
em = discord.Embed(title="AFK", description="**" + ctx.message.author.mention + "** is now AFK.", colour=0x111111)
em.set_author(name="ShugaBot", icon_url="https://i.imgur.com/07WBSqf.png")
await self.bot.purge_from(ctx.message.channel, limit=1, check=None, before=None, after="afk", around=None)
await self.bot.send_message(channel, embed=em)
@commands.command(pass_context=True, no_pm=True)
async def tss(self, ctx, Model):
"""Get versioning information for iOS devices (Beta)"""
#Your code will go here
channel = ctx.message.channel
import json
import requests
try:
jsonUrl = 'https://api.ineal.me/tss/' + Model # The API endpoint
callapi = requests.get(jsonUrl) # Fetch the API's JSON file.
json = callapi.json()
model = json[Model]
desc = "**Model:** " + model['model'] + "\n**Board:** " + model['board'] + "\n**Platform:** " + model['platform'] + "\n**Signed Versions:** "
loopCount = 0
for i in model['firmwares']:
fw = model['firmwares']
desc = desc + 'iOS ' + fw[loopCount]['version'] + " (" + fw[loopCount]['build'] + "), "
loopCount = loopCount + 1
em = discord.Embed(title="TSS", description=desc, colour=0x111111)
em.set_author(name="ShugaBot", icon_url="https://i.imgur.com/07WBSqf.png")
await self.bot.send_message(channel, embed=em)
except:
await self.bot.say("```Error: The given model is invalid. It should be in the same format of iPhone8,1.```")
@commands.command(pass_context=True, no_pm=True)
async def echo(self, ctx, *, text):
"""Send a message as the bot."""
#Your code will go here
channel = ctx.message.channel
await self.bot.purge_from(ctx.message.channel, limit=1, check=None, before=None, after=text, around=None)
await self.bot.send_message(channel, text)
@commands.command(pass_context=True, no_pm=True)
async def em(self, ctx, emTitle, *, emText):
"""Create an embed with a custom title and body."""
#Your code will go here
channel = ctx.message.channel
em = discord.Embed(title=emTitle, description=emText, colour=0x111111)
em.set_author(name=ctx.message.author, icon_url=ctx.message.author.avatar_url)
await self.bot.purge_from(ctx.message.channel, limit=1, check=None, before=None, after=emText, around=None)
await self.bot.send_message(channel, embed=em)
@commands.command(pass_context=True, no_pm=True)
async def emAdv(self, ctx, emTitle, emText, *, Color):
"""Create an embed with a custom title, body, and color"""
#Your code will go here
channel = ctx.message.channel
em = discord.Embed(title=emTitle, description=emText, colour=int(Color, 16))
em.set_author(name=ctx.message.author, icon_url=ctx.message.author.avatar_url)
await self.bot.purge_from(ctx.message.channel, limit=1, check=None, before=None, after=emText, around=None)
await self.bot.send_message(channel, embed=em)
@commands.command(pass_context=True, no_pm=True)
async def emPro(self, ctx, emTitle, emText, Color, authorName, *, authorURL):
"""Create an embed with a custom title, body, color, and author data."""
#Your code will go here
channel = ctx.message.channel
em = discord.Embed(title=emTitle, description=emText, colour=int(Color, 16))
em.set_author(name=authorName, icon_url=authorURL)
await self.bot.purge_from(ctx.message.channel, limit=1, check=None, before=None, after=emText, around=None)
await self.bot.send_message(channel, embed=em)
def setup(bot):
bot.add_cog(Core(bot))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment