Updating to new discord.py version
This commit is contained in:
parent
ed9031a1d9
commit
6f0e6737fd
@ -9,7 +9,7 @@ A Discord Bot written in Python using the Rewrite API wrapper
|
|||||||
- Discord Rewrite API Wrapper
|
- Discord Rewrite API Wrapper
|
||||||
|
|
||||||
##### You can get the Wrapper with pip:
|
##### You can get the Wrapper with pip:
|
||||||
`python -m pip install -U https://github.com/Rapptz/discord.py/archive/rewrite.zip`
|
`python -m pip install discord.py`
|
||||||
|
|
||||||
Depending on your OS and environment you need to type `python3` or another equivalent instead of `python`
|
Depending on your OS and environment you need to type `python3` or another equivalent instead of `python`
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import discord, random
|
import discord, random
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
class Fun():
|
class Fun(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
@ -11,10 +11,56 @@ class Fun():
|
|||||||
await ctx.send(ctx.author.mention + " Pong!")
|
await ctx.send(ctx.author.mention + " Pong!")
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def dice(self, ctx):
|
async def d4(self, ctx):
|
||||||
|
"""Throws a four-sided dice."""
|
||||||
|
await ctx.send(ctx.author.mention + " You rolled a D4: " + str(random.randint(1,4)))
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def d6(self, ctx):
|
||||||
"""Throws a six-sided dice."""
|
"""Throws a six-sided dice."""
|
||||||
await ctx.send(ctx.author.mention + " You rolled a D6: " + str(random.randint(1,6)))
|
await ctx.send(ctx.author.mention + " You rolled a D6: " + str(random.randint(1,6)))
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def d8(self, ctx):
|
||||||
|
"""Throws a eight-sided dice."""
|
||||||
|
await ctx.send(ctx.author.mention + " You rolled a D8: " + str(random.randint(1,8)))
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def d10(self, ctx):
|
||||||
|
"""Throws a eight-sided dice."""
|
||||||
|
await ctx.send(ctx.author.mention + " You rolled a D10: " + str(random.randint(1,10)))
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def d12(self, ctx):
|
||||||
|
"""Throws a twelve-sided dice."""
|
||||||
|
await ctx.send(ctx.author.mention + " You rolled a D12: " + str(random.randint(1,12)))
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def d20(self, ctx):
|
||||||
|
"""Throws a twenty-sided dice."""
|
||||||
|
await ctx.send(ctx.author.mention + " You rolled a D20: " + str(random.randint(1,20)))
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def d100(self, ctx):
|
||||||
|
"""Throws a hundred-sided dice."""
|
||||||
|
await ctx.send(ctx.author.mention + " You rolled a D100: " + str(random.randint(1,100)))
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def magic8ball(self,ctx, *, msg : str = None):
|
||||||
|
if msg is None:
|
||||||
|
await ctx.send(":8ball: You need a question")
|
||||||
|
else:
|
||||||
|
answers = ["Yes.", "As I see it, yes.", "Outlook good.", "For sure",
|
||||||
|
"Without a doubt.", "It is decidedly so.", "Without a doubt.",
|
||||||
|
"Maybe", "Perhaps","It is uncertain", "Dont even think about it.",
|
||||||
|
"Nope.", "Don't count on it.", "My sources say no.",
|
||||||
|
"Outlook not so good.", "Very doubtful.", "Definitely no."]
|
||||||
|
e = discord.Embed(color=0x3296ff)
|
||||||
|
e.set_author(name = str(ctx.author), icon_url=ctx.author.avatar_url)
|
||||||
|
e.add_field(name=":grey_question: Question", value=msg, inline=False)
|
||||||
|
e.add_field(name=":8ball: Answer", value=random.choice(answers), inline=False)
|
||||||
|
await ctx.send(embed=e)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def coin(self, ctx):
|
async def coin(self, ctx):
|
||||||
"""Throws a coin."""
|
"""Throws a coin."""
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import discord
|
import discord, io
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from akuma import s, c, writeServer
|
from akuma import s, c, writeServer
|
||||||
@ -17,11 +17,12 @@ ownerCommands = """```Possible Commands:
|
|||||||
owner rmAdmin <id>
|
owner rmAdmin <id>
|
||||||
```"""
|
```"""
|
||||||
|
|
||||||
class Moderation():
|
class Moderation(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#Logs
|
#Logs
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_member_join(self, member):
|
async def on_member_join(self, member):
|
||||||
if s[str(member.guild.id)]["logJoinAndLeave"] == True:
|
if s[str(member.guild.id)]["logJoinAndLeave"] == True:
|
||||||
if s[str(member.guild.id)]["joinMessage"] != "":
|
if s[str(member.guild.id)]["joinMessage"] != "":
|
||||||
@ -33,7 +34,8 @@ class Moderation():
|
|||||||
e.add_field(name="Mention", value=member.mention, inline=False)
|
e.add_field(name="Mention", value=member.mention, inline=False)
|
||||||
chan = self.bot.get_channel(s[str(member.guild.id)]["logJoinAndLeaveChannel"])
|
chan = self.bot.get_channel(s[str(member.guild.id)]["logJoinAndLeaveChannel"])
|
||||||
await chan.send(embed=e)
|
await chan.send(embed=e)
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_member_remove(self, member):
|
async def on_member_remove(self, member):
|
||||||
if s[str(member.guild.id)]["logJoinAndLeave"] == True:
|
if s[str(member.guild.id)]["logJoinAndLeave"] == True:
|
||||||
if s[str(member.guild.id)]["logJoinAndLeaveChannel"] != 0:
|
if s[str(member.guild.id)]["logJoinAndLeaveChannel"] != 0:
|
||||||
@ -44,26 +46,37 @@ class Moderation():
|
|||||||
chan = self.bot.get_channel(s[str(member.guild.id)]["logJoinAndLeaveChannel"])
|
chan = self.bot.get_channel(s[str(member.guild.id)]["logJoinAndLeaveChannel"])
|
||||||
await chan.send(embed=e)
|
await chan.send(embed=e)
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_message_edit(self, before, after):
|
async def on_message_edit(self, before, after):
|
||||||
if s[str(before.guild.id)]["logEditAndDelete"] == True and before.author.bot == False:
|
if before.guild is not None and before.author.bot == False and s[str(before.guild.id)]["logEditAndDelete"] == True:
|
||||||
if s[str(before.guild.id)]["logEditAndDeleteChannel"] != 0 and before.content != after.content:
|
if s[str(before.guild.id)]["logEditAndDeleteChannel"] != 0 and before.content != after.content:
|
||||||
e = discord.Embed(color=0xc83232)
|
e = discord.Embed(color=0x32c8c8)
|
||||||
e.set_author(name = str(before.author) + " edited a message.", icon_url=before.author.avatar_url)
|
e.set_author(name = str(before.author) + " edited a message.", icon_url=before.author.avatar_url)
|
||||||
e.add_field(name="Author ID", value=str(before.author.id), inline=False)
|
e.add_field(name="Profile", value=before.author.mention, inline=False)
|
||||||
e.add_field(name="Channel", value=str(before.channel.name), inline=False)
|
e.add_field(name="Channel", value=str(before.channel.name), inline=False)
|
||||||
e.add_field(name="Message before", value=before.content,inline=False)
|
e.add_field(name="Message before", value=before.content,inline=False)
|
||||||
e.add_field(name="Message after", value=after.content,inline=False)
|
e.add_field(name="Message after", value=after.content,inline=False)
|
||||||
chan = self.bot.get_channel(s[str(before.guild.id)]["logEditAndDeleteChannel"])
|
chan = self.bot.get_channel(s[str(before.guild.id)]["logEditAndDeleteChannel"])
|
||||||
await chan.send(embed=e)
|
await chan.send(embed=e)
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_message_delete(self, message):
|
async def on_message_delete(self, message):
|
||||||
if s[str(message.guild.id)]["logEditAndDelete"] == True and message.author.bot == False:
|
if message.guild is not None and message.author.bot == False and s[str(message.guild.id)]["logEditAndDelete"] == True:
|
||||||
if s[str(message.guild.id)]["logEditAndDeleteChannel"] != 0:
|
if s[str(message.guild.id)]["logEditAndDeleteChannel"] != 0:
|
||||||
e = discord.Embed(color=0xc83232)
|
e = discord.Embed(color=0xc83232)
|
||||||
e.set_author(name = str(message.author) + " deleted a message.", icon_url=message.author.avatar_url)
|
e.set_author(name = str(message.author) + "'s message got deleted.", icon_url=message.author.avatar_url)
|
||||||
e.add_field(name="Author ID", value=str(message.author.id), inline=False)
|
e.add_field(name="Profile", value=message.author.mention, inline=False)
|
||||||
e.add_field(name="Channel", value=str(message.channel.name), inline=False)
|
e.add_field(name="Channel", value=str(message.channel.name), inline=False)
|
||||||
e.add_field(name="Message", value=message.content,inline=False)
|
if message.content:
|
||||||
|
e.add_field(name="Message", value=message.content,inline=False)
|
||||||
|
numAtch = len(message.attachments)
|
||||||
|
if numAtch == 1:
|
||||||
|
e.add_field(name="Attachments", value="The message had " + str(numAtch) + " attachment",inline=False)
|
||||||
|
e.add_field(name="File Name", value=message.attachments[0].filename, inline=False)
|
||||||
|
elif numAtch > 1:
|
||||||
|
e.add_field(name="Attachments", value="The message had " + str(numAtch) + " attachments",inline=False)
|
||||||
|
for a in message.attachments:
|
||||||
|
e.add_field(name="File Name", value=a.filename, inline=False)
|
||||||
chan = self.bot.get_channel(s[str(message.guild.id)]["logEditAndDeleteChannel"])
|
chan = self.bot.get_channel(s[str(message.guild.id)]["logEditAndDeleteChannel"])
|
||||||
await chan.send(embed=e)
|
await chan.send(embed=e)
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ from discord.ext import commands
|
|||||||
from akuma import s
|
from akuma import s
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
class User():
|
class User(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user