-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBot.py
83 lines (66 loc) · 2.39 KB
/
Bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import discord
from discord.ext import commands
from secrets import Token as Token
bot = commands.Bot(command_prefix="!")
role_add_channel_id = 750036407757832242
@bot.event
async def on_message(message):
if bot.user == message.author:
return
if message.channel.id == role_add_channel_id:
await bot.process_commands(message)
await message.delete(delay=10)
@bot.command(name="färg", help="lägg till en färg")
async def color(payload):
if payload.channel.id == role_add_channel_id:
member = payload.author
guild = member.guild
check = True
color = discord.Colour(int(payload.message.content[6:12], base=16))
for role in member.roles:
if str(member.id) == role.name:
await role.edit(colour=(color))
await payload.channel.send(
content=f"Ändrade {member.display_name} färg till {color.value}",
delete_after=10,
)
check = False
break
if check:
await guild.create_role(
name=str(member.id), color=color, reason="färg roll"
)
for role in guild.roles:
if str(member.id) == role.name:
await member.add_roles(role)
await payload.channel.send(
content=f"Ändrade {member.display_name} färg till {color.value}",
delete_after=10,
)
break
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, discord.ext.commands.errors.CommandNotFound):
await ctx.send("detta kommandet finns inte", delete_after=15)
await ctx.delete(delay=10)
@bot.event
async def on_command_error2(ctx, error):
await ctx.send("kommand error", delete_after=15)
await ctx.delete(delay=10)
# command to test if the bot is running
@bot.command(name="test", help="test")
async def test(ctx):
response = "Jag är online!"
await ctx.send(response)
# command to test if the bot is running
@bot.command(name="ping", help="test")
async def test2(ctx):
response = "pong 🏓"
await ctx.send(response)
# print a message if the bot is online
@bot.event
async def on_ready():
print("bot connected")
# change status to online
await bot.change_presence(activity=discord.Game("FÄRG"))
bot.run(Token)