rework the whole bot for the new command system
This commit is contained in:
parent
9407111771
commit
afc80258ea
1 changed files with 249 additions and 292 deletions
541
bot.py
541
bot.py
|
@ -18,32 +18,39 @@ def mid(s, offset, amount):
|
||||||
return s[offset:offset+amount]
|
return s[offset:offset+amount]
|
||||||
|
|
||||||
token = os.environ['TOKEN']
|
token = os.environ['TOKEN']
|
||||||
|
bot = commands.Bot(command_prefix=os.environ['PREFIX'])
|
||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
async def admin(ctx):
|
|
||||||
|
def admin(ctx):
|
||||||
if ctx.guild.get_role(261603488331595776) in ctx.author.roles:
|
if ctx.guild.get_role(261603488331595776) in ctx.author.roles:
|
||||||
return True
|
return True
|
||||||
async def member(ctx):
|
def member(ctx):
|
||||||
if ctx.guild.get_role(261603747711418371) in ctx.author.roles:
|
if ctx.guild.get_role(261603747711418371) in ctx.author.roles:
|
||||||
return True
|
return True
|
||||||
def is_admin():
|
def is_admin():
|
||||||
async def predicate(ctx):
|
async def predicate(ctx):
|
||||||
await admin(ctx)
|
if ctx.guild.get_role(261603488331595776) in ctx.author.roles:
|
||||||
|
return True
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
def is_member():
|
def is_member():
|
||||||
async def predicate(ctx):
|
async def predicate(ctx):
|
||||||
await member(ctx)
|
if ctx.guild.get_role(261603747711418371) in ctx.author.roles:
|
||||||
|
return True
|
||||||
|
return commands.check(predicate)
|
||||||
|
def is_gm():
|
||||||
|
async def predicate(ctx):
|
||||||
|
if ctx.guild.get_role(511893805956595722) in ctx.author.roles:
|
||||||
|
return True
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
|
||||||
|
|
||||||
emojinumbers = ["0\u20E3", "1\u20E3" , "2\u20E3" , "3\u20E3" , "4\u20E3" , "5\u20E3" , "6\u20E3" , "7\u20E3" , "8\u20E3" , "9\u20E3"]
|
emojinumbers = ["0\u20E3", "1\u20E3" , "2\u20E3" , "3\u20E3" , "4\u20E3" , "5\u20E3" , "6\u20E3" , "7\u20E3" , "8\u20E3" , "9\u20E3"]
|
||||||
|
|
||||||
@client.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print("Bot ready on Version %s..." % discord.__version__)
|
print("Bot ready on Version %s..." % discord.__version__)
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix='!')
|
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
|
@is_admin()
|
||||||
async def test(ctx, arg):
|
async def test(ctx, arg):
|
||||||
await ctx.send(arg)
|
await ctx.send(arg)
|
||||||
|
|
||||||
|
@ -65,300 +72,250 @@ async def helpme(ctx):
|
||||||
await ctx.author.create_dm()
|
await ctx.author.create_dm()
|
||||||
await ctx.author.dm_channel.send(embed=em)
|
await ctx.author.dm_channel.send(embed=em)
|
||||||
|
|
||||||
@client.event
|
@bot.command()
|
||||||
async def on_message(message):
|
@is_member()
|
||||||
if message.content == "!help":
|
async def survey(ctx, *, arg):
|
||||||
if message.channel == message.author.dm_channel:
|
await ctx.message.delete()
|
||||||
await message.author.dm_channel.send("Sorry das geht so nicht. Bitte schreibe diese Nachricht in einen Channel auf dem SecondHemd Discord, sonst kann ich nicht sehen was du für Berechtigungen hast. Vielen Dank.")
|
answers = arg.split("|")
|
||||||
else:
|
question = answers[0]
|
||||||
await message.delete()
|
answers.remove(question)
|
||||||
if member(message):
|
desc = ""
|
||||||
if permission(message):
|
z = 1
|
||||||
admin_text = "\n\n!add = Hinzufügen einer Rolle mit Textchannel und hinzufügen von Usern zur Rolle\nNutzung: !add \"<Rolle>\" <User Mentions>\n\n!labor = bringt dich ins Labor :)\nNutzung: !labor\n\n!start = Starte ne Runde PnP\nNutzung: !start @Rolle\n\n!stop = Beende die gestartete Runde PnP\nNutzung: !stop\n\n!purge = Löschen von Nachrichten\nNutzung: !purge all|<Anzahl>|x minutes/hours/days/weeks\n\n!prune - kickt Member ohne Rolle, die 30 Tage nicht online waren\nNutzung: !prune"
|
for y in answers:
|
||||||
else:
|
desc = desc + emojinumbers[z] + " - " + y + "\n"
|
||||||
admin_text = ""
|
z = z + 1
|
||||||
em = discord.Embed(title="Hilfe",description="!survey = Umfrage mit mehreren Antwortmöglichkeiten\nNutzung: !survey <Frage> | <Antwort1> | <Antwort2> ...\n\n!vote = Ja/Nein Umfrage\nNutzung: !vote <Frage>\n\n!love = zeige einem User Liebe\nNutzung: !love <@User1> <@User2> ...\n\n!roll = Rolle einen oder mehrere Würfel\nNutzung: !roll <anzahl_optional>W<seitenzahl> (z.B. !roll W20 oder !roll 10W6)%s" % admin_text, colour=0x00FF00)
|
em = discord.Embed(title=question, description=desc, colour=0x00E0FF)
|
||||||
if message.author.dm_channel == None:
|
em.set_author(name=ctx.author.display_name, url=discord.Embed.Empty, icon_url=ctx.author.avatar_url)
|
||||||
await message.author.create_dm()
|
ask_msg = await ctx.send(content="||@here||",embed=em)
|
||||||
await message.author.dm_channel.send(embed=em)
|
a = 0
|
||||||
|
for x in emojinumbers:
|
||||||
|
if a < z and a != 0:
|
||||||
|
await ask_msg.add_reaction(x)
|
||||||
|
a = a + 1
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@is_member()
|
||||||
|
async def surveyedit(ctx, *, arg):
|
||||||
|
#Nutzung: !surveyedit ID | <Frage> | <Antwort1> | <Antwort2> ...
|
||||||
|
await ctx.message.delete()
|
||||||
|
answers = arg.split("|")
|
||||||
|
survey_id = answers[0]
|
||||||
|
question = answers[1]
|
||||||
|
answers.remove(survey_id)
|
||||||
|
answers.remove(question)
|
||||||
|
desc = ""
|
||||||
|
z = 1
|
||||||
|
for y in answers:
|
||||||
|
desc = desc + emojinumbers[z] + " - " + y + "\n"
|
||||||
|
z = z + 1
|
||||||
|
em = discord.Embed(title=question, description=desc, colour=0x00E0FF)
|
||||||
|
em.set_author(name=ctx.author.display_name, url=discord.Embed.Empty, icon_url=ctx.author.avatar_url)
|
||||||
|
survey_msg = await ctx.channel.fetch_message((int(survey_id)))
|
||||||
|
await survey_msg.edit(embed=em)
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@is_member()
|
||||||
|
async def vote(ctx, *, arg):
|
||||||
|
await ctx.message.delete()
|
||||||
|
em = discord.Embed(description=arg, colour=0x00E0FF)
|
||||||
|
em.set_author(name=ctx.author.display_name, url=discord.Embed.Empty, icon_url=ctx.author.avatar_url)
|
||||||
|
ask_msg = await ctx.send(content="||@here||",embed=em)
|
||||||
|
for x in ["✅", "❔", "❌"]:
|
||||||
|
await ask_msg.add_reaction(x)
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@is_admin()
|
||||||
|
async def say(ctx, *, arg):
|
||||||
|
await ctx.message.delete()
|
||||||
|
em = discord.Embed(description=arg, colour=0x00E0FF)
|
||||||
|
await message.channel.send(embed=em)
|
||||||
|
await message.delete()
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@is_gm()
|
||||||
|
async def start(ctx, role_id):
|
||||||
|
await ctx.message.delete()
|
||||||
|
role_id = right(left(role_id, len(role_id)-1), len(role_id) - 4)
|
||||||
|
for r in ctx.author.roles:
|
||||||
|
if str(r.id) == role_id:
|
||||||
|
role = r
|
||||||
|
em = discord.Embed(description='gespieltes PnP: %s\nTeilnehmer (zum Start):' % role.mention, colour=0x00770d)
|
||||||
|
move_member = []
|
||||||
|
for c in ctx.guild.channels:
|
||||||
|
if str(c.type) == "voice":
|
||||||
|
for m in c.members:
|
||||||
|
if role in m.roles:
|
||||||
|
move_member.append(m)
|
||||||
|
for m in move_member:
|
||||||
|
await m.move_to(bot.get_channel(435869507123281920))
|
||||||
|
em.add_field(name=":white_check_mark: " + m.display_name, value = m.mention + "ist am Start! Juhu!", inline=False)
|
||||||
|
start_msg = await bot.get_channel(435501602485305345).send(content=":game_die: **INFO: PnP Sitzung gestartet!**",embed=em)
|
||||||
|
text_file = open("start_id.txt", "w")
|
||||||
|
text_file.write(str(start_msg.id))
|
||||||
|
text_file.close()
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@is_gm()
|
||||||
|
async def stop(ctx):
|
||||||
|
await ctx.message.delete()
|
||||||
|
text_file = open("start_id.txt", "r")
|
||||||
|
start_id = text_file.read()
|
||||||
|
text_file.close()
|
||||||
|
start_msg = await bot.get_channel(435501602485305345).fetch_message(start_id)
|
||||||
|
now_time = datetime.datetime.utcnow().replace(microsecond=0)
|
||||||
|
then_time = start_msg.created_at.replace(microsecond=0)
|
||||||
|
dauer = str(now_time - then_time)
|
||||||
|
for m in client.get_channel(435869507123281920).members:
|
||||||
|
await m.move_to(client.get_channel(801869864745697280))
|
||||||
|
await start_msg.edit(content=":game_die: **INFO: PnP Sitzung beendet!** Dauer: %s" % dauer)
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@is_admin()
|
||||||
|
async def labor(ctx):
|
||||||
|
await ctx.message.delete()
|
||||||
|
await ctx.author.move_to(bot.get_channel(765601577334865972))
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@is_admin()
|
||||||
|
async def add(ctx, *, arg):
|
||||||
|
await ctx.message.delete()
|
||||||
|
try:
|
||||||
|
role_name = ctx.message.content.split("\"")[1]
|
||||||
|
text_name = role_name.lower().replace(" ", "-")
|
||||||
|
role = await ctx.guild.create_role(name=role_name, mentionable=True)
|
||||||
|
overwrites = {
|
||||||
|
ctx.guild.default_role: discord.PermissionOverwrite(read_messages=False),
|
||||||
|
role: discord.PermissionOverwrite(read_messages=True)
|
||||||
|
}
|
||||||
|
channel = await ctx.guild.create_text_channel(text_name, overwrites=overwrites, topic="Dieser Channel wurde von SecondBot erstellt.")
|
||||||
|
for user in ctx.message.mentions:
|
||||||
|
await user.add_roles(role)
|
||||||
|
em = discord.Embed(title=':loudspeaker: Ein neuer Channel für %s!' % role_name, description='Herzlich Willkommen! Es gibt nun eine neue Gruppe %s und diesen wunderbaren Channel hier! Der Channel ist nur für euch und die Admins sichtbar.' % role.mention, colour=0xffa500)
|
||||||
|
await channel.send(embed=em)
|
||||||
|
except Exception as e:
|
||||||
|
em = discord.Embed(title="Error Code", description=e, color=0xff0000)
|
||||||
|
await ctx.channel.send(content="Das hat nicht funktioniert. Syntax: !add \"<Rolle>\" <User Mentions>", embed=em, delete_after=20.0)
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@is_admin()
|
||||||
|
async def purge(ctx, *, arg):
|
||||||
|
#Nutzung: !purge all|<Anzahl>|x minutes/hours/days/weeks
|
||||||
|
await ctx.message.delete()
|
||||||
|
by_limit = False
|
||||||
|
by_time = False
|
||||||
|
try:
|
||||||
|
if ctx.message.content.split(" ")[2] == "minutes":
|
||||||
|
by_time = True
|
||||||
|
delta = datetime.timedelta(minutes=int(ctx.message.content.split(" ")[1]))
|
||||||
|
if ctx.message.content.split(" ")[2] == "hours":
|
||||||
|
by_time = True
|
||||||
|
delta = datetime.timedelta(hours=int(ctx.message.content.split(" ")[1]))
|
||||||
|
if ctx.message.content.split(" ")[2] == "days":
|
||||||
|
by_time = True
|
||||||
|
delta = datetime.timedelta(days=int(ctx.message.content.split(" ")[1]))
|
||||||
|
if ctx.message.content.split(" ")[2] == "weeks":
|
||||||
|
by_time = True
|
||||||
|
delta = datetime.timedelta(weeks=int(ctx.message.content.split(" ")[1]))
|
||||||
|
except IndexError:
|
||||||
|
try:
|
||||||
|
if ctx.message.content.split(" ")[1] == "all":
|
||||||
|
by_limit = True
|
||||||
|
limit = None
|
||||||
else:
|
else:
|
||||||
if message.author.dm_channel == None:
|
by_limit = True
|
||||||
await message.author.create_dm()
|
limit = int(ctx.message.content.split(" ")[1])
|
||||||
await message.author.dm_channel.send("Sorry, du hast leider nicht die nötigen Berechtigungen. :(")
|
except:
|
||||||
|
print("List error, ploz ignore")
|
||||||
if message.content.startswith("!survey ") and member(message):
|
except:
|
||||||
if message.content == "!survey":
|
print("List error, ploz ignore")
|
||||||
error_message = await message.channel.send("Nutzung: !survey <Frage> | <Antwort1> | <Antwort2> ...")
|
if by_time:
|
||||||
await message.delete()
|
after_time = datetime.datetime.utcnow() - delta
|
||||||
await asyncio.sleep(15)
|
question = await ctx.send("Would you really like to delete all messages of the last {} {}?".format(ctx.message.content.split(" ")[1], ctx.message.content.split(" ")[2]))
|
||||||
await error_message.delete()
|
|
||||||
else:
|
|
||||||
answers_raw = right(message.content, len(message.content)-8)
|
|
||||||
answers = answers_raw.split("|")
|
|
||||||
question = answers[0]
|
|
||||||
answers.remove(question)
|
|
||||||
desc = ""
|
|
||||||
z = 1
|
|
||||||
for y in answers:
|
|
||||||
desc = desc + emojinumbers[z] + " - " + y + "\n"
|
|
||||||
z = z + 1
|
|
||||||
em = discord.Embed(title=question, description=desc, colour=0x00E0FF)
|
|
||||||
em.set_author(name=message.author.display_name, url=discord.Embed.Empty, icon_url=message.author.avatar_url)
|
|
||||||
ask_msg = await message.channel.send(content="||@here||",embed=em)
|
|
||||||
a = 0
|
|
||||||
for x in emojinumbers:
|
|
||||||
if a < z and a != 0:
|
|
||||||
await ask_msg.add_reaction(x)
|
|
||||||
a = a + 1
|
|
||||||
await message.delete()
|
|
||||||
|
|
||||||
if message.content.startswith("!surveyedit") and member(message):
|
|
||||||
if message.content == "!surveyedit":
|
|
||||||
await message.delete()
|
|
||||||
await message.channel.send(content="Nutzung: !surveyedit ID | <Frage> | <Antwort1> | <Antwort2> ...", delete_after=15.0)
|
|
||||||
else:
|
|
||||||
await message.delete()
|
|
||||||
answers_raw = right(message.content, len(message.content)-12)
|
|
||||||
answers = answers_raw.split("|")
|
|
||||||
survey_id = answers[0]
|
|
||||||
question = answers[1]
|
|
||||||
answers.remove(survey_id)
|
|
||||||
answers.remove(question)
|
|
||||||
desc = ""
|
|
||||||
z = 1
|
|
||||||
for y in answers:
|
|
||||||
desc = desc + emojinumbers[z] + " - " + y + "\n"
|
|
||||||
z = z + 1
|
|
||||||
em = discord.Embed(title=question, description=desc, colour=0x00E0FF)
|
|
||||||
em.set_author(name=message.author.display_name, url=discord.Embed.Empty, icon_url=message.author.avatar_url)
|
|
||||||
survey_msg = await message.channel.fetch_message((int(survey_id)))
|
|
||||||
await survey_msg.edit(embed=em)
|
|
||||||
#----------------------------------------------------------------------------------------
|
|
||||||
if message.content.startswith("!vote") and member(message):
|
|
||||||
if message.content == "!vote":
|
|
||||||
error_message = await message.channel.send("Nutzung: !vote <Frage>")
|
|
||||||
await message.delete()
|
|
||||||
await asyncio.sleep(10)
|
|
||||||
await error_message.delete()
|
|
||||||
else:
|
|
||||||
em = discord.Embed(description=str(right(message.content,len(message.content)-6)), colour=0x00E0FF)
|
|
||||||
em.set_author(name=message.author.display_name, url=discord.Embed.Empty, icon_url=message.author.avatar_url)
|
|
||||||
ask_msg = await message.channel.send(content="||@here||",embed=em)
|
|
||||||
for x in ["✅", "❔", "❌"]:
|
|
||||||
await ask_msg.add_reaction(x)
|
|
||||||
await message.delete()
|
|
||||||
|
|
||||||
if message.content.startswith("!say") and permission(message):
|
|
||||||
em = discord.Embed(description=str(right(message.content,len(message.content)-5)), colour=0x00E0FF)
|
|
||||||
await message.channel.send(embed=em)
|
|
||||||
await message.delete()
|
|
||||||
|
|
||||||
#move Bot
|
|
||||||
if message.content.startswith("!start") and permission(message):
|
|
||||||
if message.content == ("!start"):
|
|
||||||
error_message = await message.channel.send( "Nutzung: !start @Rolle")
|
|
||||||
await asyncio.sleep(6)
|
|
||||||
await message.delete()
|
|
||||||
await error_message.delete()
|
|
||||||
else:
|
|
||||||
role_id = message.content.split(" ")[1]
|
|
||||||
role_id = right(left(role_id, len(role_id)-1), len(role_id) - 4)
|
|
||||||
await message.delete()
|
|
||||||
for r in message.author.roles:
|
|
||||||
if str(r.id) == role_id:
|
|
||||||
role = r
|
|
||||||
em = discord.Embed(description='gespieltes PnP: %s\nTeilnehmer (zum Start):' % role.mention, colour=0x00770d)
|
|
||||||
move_member = []
|
|
||||||
for c in message.guild.channels:
|
|
||||||
if str(c.type) == "voice":
|
|
||||||
for m in c.members:
|
|
||||||
if role in m.roles:
|
|
||||||
move_member.append(m)
|
|
||||||
for m in move_member:
|
|
||||||
await m.move_to(client.get_channel(435869507123281920))
|
|
||||||
em.add_field(name=":white_check_mark: " + m.display_name, value = m.mention + "ist am Start! Juhu!", inline=False)
|
|
||||||
start_msg = await client.get_channel(435501602485305345).send(content=":game_die: **INFO: PnP Sitzung gestartet!**",embed=em)
|
|
||||||
text_file = open("start_id.txt", "w")
|
|
||||||
text_file.write(str(start_msg.id))
|
|
||||||
text_file.close()
|
|
||||||
|
|
||||||
if message.content == "!stop" and permission(message):
|
|
||||||
text_file = open("start_id.txt", "r")
|
|
||||||
start_id = text_file.read()
|
|
||||||
text_file.close()
|
|
||||||
start_msg = await message.channel.fetch_message(start_id)
|
|
||||||
now_time = datetime.datetime.utcnow().replace(microsecond=0)
|
|
||||||
then_time = start_msg.created_at.replace(microsecond=0)
|
|
||||||
dauer = str(now_time - then_time)
|
|
||||||
for m in client.get_channel(435869507123281920).members:
|
|
||||||
await m.move_to(client.get_channel(801869864745697280))
|
|
||||||
await message.delete()
|
|
||||||
await start_msg.edit(content=":game_die: **INFO: PnP Sitzung beendet!** Dauer: %s" % dauer)
|
|
||||||
|
|
||||||
if message.content == "!labor" and permission(message):
|
|
||||||
await message.author.move_to(client.get_channel(765601577334865972))
|
|
||||||
await message.delete()
|
|
||||||
|
|
||||||
if message.content.startswith("!add") and permission(message):
|
|
||||||
if message.content == "!add":
|
|
||||||
explain_msg = await message.channel.send("Nutzung: !add \"<Rolle>\" <User Mentions>")
|
|
||||||
await message.delete()
|
|
||||||
await asyncio.sleep(10)
|
|
||||||
await explain_msg.delete()
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
role_name = message.content.split("\"")[1]
|
|
||||||
text_name = role_name.lower().replace(" ", "-")
|
|
||||||
role = await message.guild.create_role(name=role_name, mentionable=True)
|
|
||||||
overwrites = {
|
|
||||||
message.guild.default_role: discord.PermissionOverwrite(read_messages=False),
|
|
||||||
role: discord.PermissionOverwrite(read_messages=True)
|
|
||||||
}
|
|
||||||
channel = await message.guild.create_text_channel(text_name, overwrites=overwrites, topic="Dieser Channel wurde von SecondBot erstellt.")
|
|
||||||
for user in message.mentions:
|
|
||||||
await user.add_roles(role)
|
|
||||||
await message.delete()
|
|
||||||
em = discord.Embed(title=':loudspeaker: Ein neuer Channel für %s!' % role_name, description='Herzlich Willkommen! Es gibt nun eine neue Gruppe %s und diesen wunderbaren Channel hier! Der Channel ist nur für euch und die Admins sichtbar.' % role.mention, colour=0xffa500)
|
|
||||||
await channel.send(embed=em)
|
|
||||||
except Exception as e:
|
|
||||||
em = discord.Embed(title="Error Code", description=e, color=0xff0000)
|
|
||||||
error_message = await message.channel.send(content="Das hat nicht funktioniert. Syntax: !add \"<Rolle>\" <User Mentions>", embed=em)
|
|
||||||
await message.delete()
|
|
||||||
await asyncio.sleep(15)
|
|
||||||
await error_message.delete()
|
|
||||||
|
|
||||||
if message.content.startswith("!purge") and permission(message):
|
|
||||||
await message.delete()
|
|
||||||
if message.content == "!purge":
|
|
||||||
await message.channel.send(content="Nutzung: !purge all|<Anzahl>|x minutes/hours/days/weeks", delete_after=10.0)
|
|
||||||
else:
|
|
||||||
by_limit = False
|
|
||||||
by_time = False
|
|
||||||
try:
|
|
||||||
if message.content.split(" ")[2] == "minutes":
|
|
||||||
by_time = True
|
|
||||||
delta = datetime.timedelta(minutes=int(message.content.split(" ")[1]))
|
|
||||||
if message.content.split(" ")[2] == "hours":
|
|
||||||
by_time = True
|
|
||||||
delta = datetime.timedelta(hours=int(message.content.split(" ")[1]))
|
|
||||||
if message.content.split(" ")[2] == "days":
|
|
||||||
by_time = True
|
|
||||||
delta = datetime.timedelta(days=int(message.content.split(" ")[1]))
|
|
||||||
if message.content.split(" ")[2] == "weeks":
|
|
||||||
by_time = True
|
|
||||||
delta = datetime.timedelta(weeks=int(message.content.split(" ")[1]))
|
|
||||||
except IndexError:
|
|
||||||
try:
|
|
||||||
if message.content.split(" ")[1] == "all":
|
|
||||||
by_limit = True
|
|
||||||
limit = None
|
|
||||||
else:
|
|
||||||
by_limit = True
|
|
||||||
limit = int(message.content.split(" ")[1])
|
|
||||||
except:
|
|
||||||
print("List error, ploz ignore")
|
|
||||||
except:
|
|
||||||
print("List error, ploz ignore")
|
|
||||||
if by_time:
|
|
||||||
after_time = datetime.datetime.utcnow() - delta
|
|
||||||
question = await message.channel.send("Would you really like to delete all messages of the last {} {}?".format(message.content.split(" ")[1], message.content.split(" ")[2]))
|
|
||||||
def check(reaction, user):
|
|
||||||
return user == message.author and str(reaction.emoji) == "✅"
|
|
||||||
await question.add_reaction("✅")
|
|
||||||
try:
|
|
||||||
reaction, user = await client.wait_for("reaction_add", timeout=60.0, check=check)
|
|
||||||
except asyncio.TimeoutError:
|
|
||||||
await question.delete()
|
|
||||||
else:
|
|
||||||
await question.delete()
|
|
||||||
deleted = await message.channel.purge(limit=200, after=after_time)
|
|
||||||
await message.channel.send(content='Ich habe {} Nachrichten gelöscht.'.format(len(deleted)), delete_after=5.0)
|
|
||||||
if by_limit:
|
|
||||||
if limit == None:
|
|
||||||
count = "alle"
|
|
||||||
else:
|
|
||||||
count = str(limit)
|
|
||||||
question = await message.channel.send("Sollen wirklich {} Nachrichten gelöscht werden?".format(count))
|
|
||||||
def check(reaction, user):
|
|
||||||
return user == message.author and str(reaction.emoji) == "✅"
|
|
||||||
await question.add_reaction("✅")
|
|
||||||
try:
|
|
||||||
reaction, user = await client.wait_for("reaction_add", timeout=60.0, check=check)
|
|
||||||
except asyncio.TimeoutError:
|
|
||||||
await question.delete()
|
|
||||||
else:
|
|
||||||
await question.delete()
|
|
||||||
deleted = await message.channel.purge(limit=limit)
|
|
||||||
await message.channel.send(content='Ich habe {} Nachrichten gelöscht.'.format(len(deleted)), delete_after=5.0)
|
|
||||||
|
|
||||||
if message.content.startswith("!love") and member(message):
|
|
||||||
await message.delete()
|
|
||||||
for user in message.mentions:
|
|
||||||
if user.dm_channel == None:
|
|
||||||
await user.create_dm()
|
|
||||||
await user.dm_channel.send("❤️")
|
|
||||||
|
|
||||||
if message.content.endswith("!?") and member(message):
|
|
||||||
for x in ["✅", "❌"]:
|
|
||||||
await message.add_reaction(x)
|
|
||||||
|
|
||||||
if message.content.startswith("!prune") and permission(message):
|
|
||||||
await message.delete()
|
|
||||||
count = await message.guild.estimate_pruned_members(days=30)
|
|
||||||
question = await message.channel.send("Sollen wirklich {} Leichen gekickt werden?".format(count))
|
|
||||||
def check(reaction, user):
|
def check(reaction, user):
|
||||||
return user == message.author and str(reaction.emoji) == "✅"
|
return user == ctx.author and str(reaction.emoji) == "✅"
|
||||||
await question.add_reaction("✅")
|
await question.add_reaction("✅")
|
||||||
try:
|
try:
|
||||||
reaction, user = await client.wait_for("reaction_add", timeout=60.0, check=check)
|
reaction, user = await bot.wait_for("reaction_add", timeout=60.0, check=check)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
await question.delete()
|
await question.delete()
|
||||||
else:
|
else:
|
||||||
await question.delete()
|
await question.delete()
|
||||||
deleted = await message.guild.prune_members(days=30)
|
deleted = await ctx.channel.purge(limit=200, after=after_time)
|
||||||
await message.channel.send(content='Ich habe {} Leichen beseitigt.'.format(deleted), delete_after=5.0)
|
await ctx.send(content='Ich habe {} Nachrichten gelöscht.'.format(len(deleted)), delete_after=5.0)
|
||||||
|
if by_limit:
|
||||||
if message.content.startswith("!roll") and member(message):
|
if limit == None:
|
||||||
if message.content == "!roll":
|
count = "alle"
|
||||||
await message.delete()
|
|
||||||
await message.channel.send(content="Nutzung: !roll <anzahl_optional>W<seitenzahl> (z.B. !roll W20 oder !roll 10W6)", delete_after=10.0)
|
|
||||||
else:
|
else:
|
||||||
rollt = 0
|
count = str(limit)
|
||||||
rolle = " "
|
question = await ctx.send("Sollen wirklich {} Nachrichten gelöscht werden?".format(count))
|
||||||
roll = message.content.split(" ")[1].lower()
|
def check(reaction, user):
|
||||||
if "d" in roll:
|
return user == ctx.author and str(reaction.emoji) == "✅"
|
||||||
rolls = "d"
|
await question.add_reaction("✅")
|
||||||
if "w" in roll:
|
try:
|
||||||
rolls = "w"
|
reaction, user = await bot.wait_for("reaction_add", timeout=60.0, check=check)
|
||||||
rollc = roll.split(rolls)[0]
|
except asyncio.TimeoutError:
|
||||||
if rollc == "":
|
await question.delete()
|
||||||
rollc = 1
|
else:
|
||||||
else:
|
await question.delete()
|
||||||
rollc = int(rollc)
|
deleted = await ctx.channel.purge(limit=limit)
|
||||||
rolld = int(roll.split(rolls)[1])
|
await ctx.send(content='Ich habe {} Nachrichten gelöscht.'.format(len(deleted)), delete_after=5.0)
|
||||||
for x in range(rollc):
|
|
||||||
rollo = random.randint(1, rolld)
|
|
||||||
rollt = rollt + rollo
|
|
||||||
rolle = rolle + " :game_die: " + str(rollo) + " "
|
|
||||||
if rollc > 1:
|
|
||||||
rolltotal = "Total: " + str(rollt)
|
|
||||||
else:
|
|
||||||
rolltotal = ""
|
|
||||||
if rollc > 12:
|
|
||||||
rolltotal = rolle + "\n" + rolltotal
|
|
||||||
rolle = ""
|
|
||||||
em = discord.Embed(title=rolle, description=rolltotal, colour=0x009933)
|
|
||||||
await message.channel.send(embed=em)
|
|
||||||
|
|
||||||
#Shiba Bilder vom Shiba Discord auf den SH Discord hauen
|
@bot.command()
|
||||||
if message.channel.id == 549177598916296723:
|
@is_member()
|
||||||
if not message.is_system() and len(message.attachments) > 0:
|
async def love(ctx, *, arg):
|
||||||
for a in message.attachments:
|
await ctx.message.delete()
|
||||||
await client.get_channel(775390209793064980).send(content=a.url)
|
for user in ctx.message.mentions:
|
||||||
|
if user.dm_channel == None:
|
||||||
|
await user.create_dm()
|
||||||
|
await user.dm_channel.send("❤️")
|
||||||
|
|
||||||
if message.content.startswith("!print") and permission(message):
|
@bot.command()
|
||||||
print(message.content)
|
@is_admin()
|
||||||
await message.delete()
|
async def prune(ctx):
|
||||||
|
await ctx.message.delete()
|
||||||
|
count = await ctx.guild.estimate_pruned_members(days=30)
|
||||||
|
question = await ctx.channel.send("Sollen wirklich {} Leichen gekickt werden?".format(count))
|
||||||
|
def check(reaction, user):
|
||||||
|
return user == ctx.author and str(reaction.emoji) == "✅"
|
||||||
|
await question.add_reaction("✅")
|
||||||
|
try:
|
||||||
|
reaction, user = await bot.wait_for("reaction_add", timeout=60.0, check=check)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
await question.delete()
|
||||||
|
else:
|
||||||
|
await question.delete()
|
||||||
|
deleted = await ctx.guild.prune_members(days=30)
|
||||||
|
await ctx.send(content='Ich habe {} Leichen beseitigt.'.format(deleted), delete_after=5.0)
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@is_member()
|
||||||
|
async def roll(ctx, arg):
|
||||||
|
await ctx.message.delete()
|
||||||
|
rollt = 0
|
||||||
|
rolle = " "
|
||||||
|
roll = arg.lower()
|
||||||
|
if "d" in roll:
|
||||||
|
rolls = "d"
|
||||||
|
if "w" in roll:
|
||||||
|
rolls = "w"
|
||||||
|
rollc = roll.split(rolls)[0]
|
||||||
|
if rollc == "":
|
||||||
|
rollc = 1
|
||||||
|
else:
|
||||||
|
rollc = int(rollc)
|
||||||
|
rolld = int(roll.split(rolls)[1])
|
||||||
|
for x in range(rollc):
|
||||||
|
rollo = random.randint(1, rolld)
|
||||||
|
rollt = rollt + rollo
|
||||||
|
rolle = rolle + " :game_die: " + str(rollo) + " "
|
||||||
|
if rollc > 1:
|
||||||
|
rolltotal = "Total: " + str(rollt)
|
||||||
|
else:
|
||||||
|
rolltotal = ""
|
||||||
|
if rollc > 12:
|
||||||
|
rolltotal = rolle + "\n" + rolltotal
|
||||||
|
rolle = ""
|
||||||
|
em = discord.Embed(title=rolle, description=rolltotal, colour=0x009933)
|
||||||
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
client.run(token)
|
bot.run(token)
|
Loading…
Reference in a new issue