Esempio n. 1
0
async def on_ready():
    logger.info('We have logged in as {0.user}'.format(client))
    activity = discord.Game("Use ?prefix to get prefix")
    await client.change_presence(activity = activity)
Esempio n. 2
0
async def on_ready():
    channel = discord.utils.get(client.get_all_channels(), name='📃・log')
    await client.change_presence(game=discord.Game(name= "Prefix: S!, s!"))
    print("The bot is online and connected with Discord!") 
    await client.send_message(channel, ":a_sucess: **Update nahrán** :thumbsup:")
Esempio n. 3
0
async def on_ready():
    print(".Bot Is ready!")
    await Client.change_status(game=discord.Game(
        name="!help <> YGamesAssistant"))
Esempio n. 4
0
async def on_ready():
    print('We have logged in as {0.user}'.format(client))
    await client.change_presence(activity=discord.Game(
        name='.vstatus | github.com/gg2001/EmailBot'))
 async def on_ready():
     print("Bot started and connected to Discord...")
     now = datetime.now()
     f = now.strftime("%d.%m.%Y %H:%M")
     await client.change_presence(activity=discord.Game(
         name=f"({f}): {response[1]}"))
Esempio n. 6
0
async def on_ready():
    """Ready message for when the bot is online."""
    await client.change_presence(activity=discord.Game(name='Quiz Bowl!'))
    print("Activity live!")
    print("Quizbowl Bot online!")
Esempio n. 7
0
 async def on_ready(self) -> None:
     prefix = environ["PREFIX"]
     await self.change_presence(activity=discord.Game(name=f"prefix: {prefix}"))
Esempio n. 8
0
async def on_ready():
    await client.change_presence(status=discord.Status.idle,
                                 activity=discord.Game("Listening to .help"))
    print("I am online")
Esempio n. 9
0
async def on_ready():
    print('Logged in as {}'.format(bot.user))
    await bot.change_presence(activity=discord.Game("Mex"))
Esempio n. 10
0
    print(f'Checking for git commit failed: {type(e).__name__} {e}')
    commit = '<unknown>'

try:
    branch = check_output(['git', 'rev-parse', '--abbrev-ref',
                           'HEAD']).decode()[:-1]
except CalledProcessError as e:
    print(f'Checking for git branch failed: {type(e).__name__} {e}')
    branch = '<unknown>'

print(f'Starting discord-mod-mail {version}!')

config = configparser.ConfigParser()
config.read('config.ini')

client = discord.Client(activity=discord.Game(name=config['Main']['playing']),
                        max_messages=100)
client.channel: discord.TextChannel

client.already_ready = False

client.last_id = 'uninitialized'

# to be filled from ignored.json later
ignored_users = []

if os.path.isfile('ignored.json'):
    with open('ignored.json', 'r') as f:
        ignored_users = json.load(f)
else:
    with open('ignored.json', 'w') as f:
Esempio n. 11
0
async def on_message(message):
    if client.channel.guild.me.activity is None or client.channel.guild.me.activity.name != config[
            'Main']['playing']:
        await client.change_presence(activity=discord.Game(
            name=config['Main']['playing']))
    author = message.author
    if author == client.user:
        return
    if not client.already_ready:
        return

    if type(message.channel) is discord.DMChannel:
        if author.id in ignored_users:
            return
        if author.id not in anti_spam_check:
            anti_spam_check[author.id] = 0

        anti_spam_check[author.id] += 1
        if anti_spam_check[author.id] >= int(config['AntiSpam']['messages']):
            if author.id not in ignored_users:  # prevent duplicates
                ignored_users.append(author.id)
            with open('ignored.json', 'w') as f:
                json.dump(ignored_users, f)
            await client.channel.send(
                f'{author.id} {author.mention} auto-ignored due to spam. '
                f'Use `{config["Main"]["command_prefix"]}unignore` to reverse.'
            )
            return

        # for the purpose of nicknames, if anys
        for server in client.guilds:
            member = server.get_member(author.id)
            if member:
                author = member
            break

        embed = discord.Embed(color=gen_color(int(author.id)),
                              description=message.content)
        if isinstance(author, discord.Member) and author.nick:
            author_name = f'{author.nick} ({author})'
        else:
            author_name = str(author)
        embed.set_author(name=author_name,
                         icon_url=author.avatar_url
                         if author.avatar else author.default_avatar_url)

        to_send = f'{author.id}'
        if message.attachments:
            attachment_urls = []
            for attachment in message.attachments:
                attachment_urls.append(
                    f'[{attachment.filename}]({attachment.url})')
            attachment_msg = '\N{BULLET} ' + '\n\N{BULLET} '.join(
                attachment_urls)
            embed.add_field(name='Attachments',
                            value=attachment_msg,
                            inline=False)
        await client.channel.send(to_send, embed=embed)
        client.last_id = author.id
        await asyncio.sleep(int(config['AntiSpam']['seconds']))
        anti_spam_check[author.id] -= 1

    elif message.channel == client.channel:
        if message.content.startswith(config['Main']['command_prefix']):
            # this might be the wrong way
            command_split = message.content[
                len(config['Main']['command_prefix']):].strip().split(
                    ' ', maxsplit=1)
            command_name = command_split[0]
            try:
                command_contents = command_split[1]
            except IndexError:
                command_contents = ''

            if command_name == 'ignore':
                if not command_contents:
                    await client.channel.send('Did you forget to enter an ID?')
                else:
                    try:
                        user_id = int(
                            command_contents.split(' ', maxsplit=1)[0])
                    except ValueError:
                        await client.channel.send('Could not convert to int.')
                        return
                    if user_id in ignored_users:
                        await client.channel.send(
                            f'{author.mention} {user_id} is already ignored.')
                    else:
                        ignored_users.append(user_id)
                        with open('ignored.json', 'w') as f:
                            json.dump(ignored_users, f)
                        await client.channel.send(
                            f'{author.mention} {user_id} is now ignored. Messages from this user will not appear. '
                            f'Use `{config["Main"]["command_prefix"]}unignore` to reverse.'
                        )

            elif command_name == 'unignore':
                if not command_contents:
                    await client.channel.send('Did you forget to enter an ID?')
                else:
                    try:
                        user_id = int(
                            command_contents.split(' ', maxsplit=1)[0])
                    except ValueError:
                        await client.channel.send('Could not convert to int.')
                        return
                    if user_id not in ignored_users:
                        await client.channel.send(
                            f'{author.mention} {user_id} is not ignored.')
                    else:
                        ignored_users.remove(user_id)
                        with open('ignored.json', 'w') as f:
                            json.dump(ignored_users, f)
                        await client.channel.send(
                            f'{author.mention} {user_id} is no longer ignored. Messages from this user will appear '
                            f'again. Use `{config["Main"]["command_prefix"]}ignore` to reverse.'
                        )

            elif command_name == 'fixgame':
                await client.change_presence(activity=None)
                await client.change_presence(activity=discord.Game(
                    name=config['Main']['playing']))
                await client.channel.send('Game presence re-set.')

            elif command_name == 'm':
                await client.channel.send(
                    f'{client.last_id} <@!{client.last_id}>')

            else:
                if command_name not in anti_duplicate_replies:
                    anti_duplicate_replies[command_name] = False
                elif anti_duplicate_replies[command_name]:
                    await client.channel.send(
                        f'{author.mention} Your message was not sent to prevent multiple replies '
                        f'to the same person within 2 seconds.')
                    return
                anti_duplicate_replies[command_name] = True
                if not command_contents:
                    await client.channel.send(
                        'Did you forget to enter a message?')
                else:
                    for server in client.guilds:
                        member = server.get_member(int(command_name))
                        if member:
                            embed = discord.Embed(color=gen_color(
                                int(command_name)),
                                                  description=command_contents)
                            if config['Main']['anonymous_staff']:
                                to_send = 'Staff reply: '
                            else:
                                to_send = f'{author.mention}: '
                            to_send += command_contents
                            try:
                                await member.send(to_send)
                                header_message = f'{author.mention} replying to {member.id} {member.mention}'
                                if member.id in ignored_users:
                                    header_message += ' (replies ignored)'
                                await client.channel.send(header_message,
                                                          embed=embed)
                                await message.delete()
                            except discord.errors.Forbidden:
                                await client.channel.send(
                                    f'{author.mention} {member.mention} has disabled DMs or is not in a shared server.'
                                )
                            break
                    else:
                        await client.channel.send(
                            f'Failed to find user with ID {command_name}')
                await asyncio.sleep(2)
                anti_duplicate_replies[command_name] = False
Esempio n. 12
0
async def game(ctx, *, message):  # b'\xfc'
    await ctx.message.delete()
    game = discord.Game(name=message)
    await bot.change_presence(activity=game)
Esempio n. 13
0
async def on_ready():
    await client.change_presence(activity=discord.Game(
        name='A game with your life'))
    print("Ready to rumble!")
Esempio n. 14
0
async def on_ready():
    print(client.user.id)
    print("ready")
    game = discord.Game("남하세 코인")
    await client.change_presence(status=discord.Status.online, activity=game)
Esempio n. 15
0
 async def on_ready(self):
     print ("------")
     print ("Hey, my name is " + self.bot.user.name + ".")
     print ("My ID is " + self.bot.user.id)
     print ("------")
     await self.bot.change_presence(game=discord.Game(name='v2'))
Esempio n. 16
0
async def on_ready():
    print('Logged in as {}'.format(LuteBot.user))
    await LuteBot.change_presence(activity=discord.Game('Steenwijker Courant'))
Esempio n. 17
0
 async def on_ready(self):
     await self.change_presence(activity=discord.Game("Supreme Info"),
                                status=discord.Status.online,
                                afk=False)
     print(Fore.GREEN + "Bot ready")
import validators

load_dotenv()

# Constants

TOKEN = os.getenv('DISCORD_TOKEN')
# minimum master password length
MIN_LENGTH = 7

# Global variables

# stores master passwords of logged in users (uid is the key)
users = dict()
# activity message
activity = discord.Game(name="!mate")
# bot client
client = commands.Bot(
    command_prefix=commands.when_mentioned_or('!'),
    description="Mate - The Password Manager Bot",
    help_command=commands.DefaultHelpCommand(no_category="Commands"))

# Helper functions


def hash(password):
    salt = bcrypt.gensalt()
    return bcrypt.hashpw(password.encode(), salt)


def valid_password(masterpass, hashed):
Esempio n. 19
0
async def on_ready():
    await client.change_presence(status=discord.Status.online,
                                 activity=discord.Game('running in #music'))
    print("online")
Esempio n. 20
0
async def updatePresence(_BOT: commands.Bot):
    await _BOT.change_presence(activity=discord.Game(
        name=ACTIVITYLIST[random.randrange(len(ACTIVITYLIST))]))
    await asyncio.sleep(43200)
Esempio n. 21
0
 async def on_ready(self):
     print('로그인: {0}({0.id})'.format(self.bot.user))
     await self.bot.change_presence(status=discord.Status.online,
                                    activity=discord.Game(';도움 입력'))
Esempio n. 22
0
jsonCheck('timezones')
#jsonCheck('embeds')

if TOKEN is None:
    try: # TOKEN
        TOKEN = sys.argv[1]
    except:
        logging.warning("Unable to get token, you must put it as the first argument after the file name, e.g python luigi.py 'TOKEN' or you can edit the code directly.")
        exit()
with open("prefixes.json","r") as f:
    prefixes = json.load(f)

def prefix(bot, message):
    return str(prefixes.get(str(message.guild.id), default_prefix)) if message.guild != None else default_prefix

game = discord.Game('Starting Up ⬆')
bot = commands.Bot(command_prefix=prefix,description=description,activity=game)
bot.channel_names = channel_names
channel_names = None
bot.update = 0
on = {}
bot.question = {}
bot.answer = {}
bot.msg = {}
bot.embed = {}
bot.prevuser = {}
bot.origauthor = {}
bot.help_message = help_message
help_message = None

try:
Esempio n. 23
0
async def watch(ctx, *args):
    await bot.change_presence(game=discord.Game(name=" ".join(args), type=3))
Esempio n. 24
0
async def on_ready():
    print("Ready!!!!!")
    game = discord.Game("$info for bot info")
    await bot.change_presence(status=discord.Status.online, activity=game)
Esempio n. 25
0
    async def on_ready(self):
        print(f"\nBot Online and logged in as: {self.bot.user.name}.")

        await self.bot.change_presence(activity=discord.Game(
            name='Mount & Blade II: Bannerlord'))
Esempio n. 26
0
async def pureityuudadada(ctx, *, st):
    if ctx.message.author.id in [709445238468509728]:  # このidのとこは自身のIDに変更してね
        await bot.change_presence(activity=discord.Game(name=st))
        await ctx.send(embed=discord.Embed(title="変更しました!", description=f"{st}"))
    else:
        await ctx.send(embed=discord.Embed(title="あなたは違いますよ!?", description="何しているんですか!?"))
Esempio n. 27
0
async def change_status():
    await client.change_presence(activity=discord.Game(next(status)))
Esempio n. 28
0
async def status_task():
    users = len(set(bot.get_all_members()))
    while True:
        await bot.change_presence(activity=discord.Game(
            name=f'&help | {str(len(bot.guilds))} guilds', type=2))
        await asyncio.sleep(30)
Esempio n. 29
0
async def on_ready():
    await client.change_presence(activity=discord.Game('!help for commands'))
    print('Bot is online')
Esempio n. 30
0
async def on_ready():
    print('Bot\'s on. Here is the invite link: https://discord.com/api/oauth2/'
          'authorize?client_id=828005083714814002&permissions=8&scope=bot')
    await bot.change_presence(
        status=discord.Status.idle,
        activity=discord.Game('!!help || In development...'))