1import discord
2
3client = discord.Client()
4
5@client.event
6async def on_ready():
7 print('We have logged in as {0.user}'.format(client))
8
9@client.event
10async def on_message(message):
11 if message.author == client.user:
12 return
13
14 if message.content.startswith('$hello'):
15 await message.channel.send('Hello!')
16
17client.run('your token here')
18
1#Anything commented out is optional
2
3import discord
4from discord.ext import commands
5
6bot = commands.Bot(command_prefix='prefix here')
7
8@bot.event
9async def on_ready():
10# await bot.change_presence(activity=discord.Game(name="Rich Presence Here"))
11 print('Logged in as: ' + bot.user.name)
12 print('Ready!\n')
13
14@bot.command()
15async def commandname(ctx, *, somevariable)
16#If you don't need a variable, then you only need (ctx)
17# """Command description"""
18 Code goes here
19 await ctx.send('Message')
20
21bot.run('yourtoken')
1import discord
2
3client = discord.Client()
4
5@client.event
6async def on_ready():
7 print('Logged in as {0.user}'.format(client))
8
9@client.event
10async def on_message(message):
11 if message.author == client.user:
12 return
13
14 if message.content.startswith('$hello'):
15 await message.channel.send('Hello!')
16
17client.run('your token here')
1import discord
2
3class MyClient(discord.Client):
4
5 async def on_ready(self):
6 print('Logged on as', self.user)
7
8 async def on_message(self, message):
9 word_list = ['cheat', 'cheats', 'hack', 'hacks', 'internal', 'external', 'ddos', 'denial of service']
10
11 # don't respond to ourselves
12 if message.author == self.user:
13 return
14
15 messageContent = message.content
16 if len(messageContent) > 0:
17 for word in word_list:
18 if word in messageContent:
19 await message.delete()
20 await message.channel.send('Do not say that!')
21
22 messageattachments = message.attachments
23 if len(messageattachments) > 0:
24 for attachment in messageattachments:
25 if attachment.filename.endswith(".dll"):
26 await message.delete()
27 await message.channel.send("No DLL's allowed!")
28 elif attachment.filename.endswith('.exe'):
29 await message.delete()
30 await message.channel.send("No EXE's allowed!")
31 else:
32 break
33
34client = MyClient()
35client.run('token here')