felixrandle / sheffield-discord-bot Goto Github PK
View Code? Open in Web Editor NEWDiscord bot for the sheffield computer science server.
License: GNU General Public License v3.0
Discord bot for the sheffield computer science server.
License: GNU General Public License v3.0
utils.py
steadily expanded as more cogs have been developed, so I believe that it should be reorganised into submodules.
2 Tables
Settings
Int, String, String
Id, Identifier, DefaultValue
GuildSettings
Id, GuildId, SettingId, Value
Needs a public interface so cogs can register settings for themselves
e.g.
register_setting("christmasMode", "false")
When pulling a setting, if no entry for the guild, use default value.
GuildSettings entry only exists once it has been explicitly set.
Similar to existing mention system for mentioning compfessions in conversation, but for within compfessions themselves
4|Discord | Traceback (most recent call last):
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/connections/connection.py", line 32, in _run
4|Discord | result = wrapped(self, query, bindings, *args, **kwargs)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/connections/connection.py", line 265, in statement
4|Discord | return self._new_cursor().execute(query, bindings)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/MySQLdb/cursors.py", line 209, in execute
4|Discord | res = self._query(query)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/MySQLdb/cursors.py", line 315, in _query
4|Discord | db.query(q)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/MySQLdb/connections.py", line 239, in query
4|Discord | _mysql.connection.query(self, query)
4|Discord | MySQLdb._exceptions.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`sheffieldcompsci`.`voice`, CONSTRAINT `voice_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`))')
4|Discord |
4|Discord | During handling of the above exception, another exception occurred:
4|Discord |
4|Discord | Traceback (most recent call last):
4|Discord | File "/usr/local/lib/python3.6/dist-packages/discord/ext/tasks/__init__.py", line 120, in _loop
4|Discord | raise exc
4|Discord | File "/usr/local/lib/python3.6/dist-packages/discord/ext/tasks/__init__.py", line 98, in _loop
4|Discord | await self.coro(*args, **kwargs)
4|Discord | File "/data/Sheffield-Discord-Bot/cogs/logging.py", line 140, in voice_channel_check
4|Discord | guild_id=guild.id)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/orm/model.py", line 461, in first_or_create
4|Discord | return cls.create(**attributes)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/orm/model.py", line 422, in create
4|Discord | model.save()
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/orm/model.py", line 1630, in save
4|Discord | saved = self._perform_insert(query, options)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/orm/model.py", line 1701, in _perform_insert
4|Discord | self._insert_and_set_id(query, attributes)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/orm/model.py", line 1723, in _insert_and_set_id
4|Discord | id = query.insert_get_id(attributes, key_name)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/orm/builder.py", line 1179, in call
4|Discord | result = attribute(*args, **kwargs)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/query/builder.py", line 1400, in insert_get_id
4|Discord | return self._processor.process_insert_get_id(self, sql, values, sequence)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/query/processors/mysql_processor.py", line 28, in process_insert_get_id
4|Discord | query.get_connection().insert(sql, values)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/connections/connection.py", line 250, in insert
4|Discord | return self.statement(query, bindings)
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/connections/connection.py", line 35, in _run
4|Discord | e, query, bindings, wrapped
4|Discord | File "/usr/local/lib/python3.6/dist-packages/orator/connections/connection.py", line 357, in _try_again_if_caused_by_lost_connection
4|Discord | raise QueryException(query, bindings, e)
4|Discord | orator.exceptions.query.QueryException: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`sheffieldcompsci`.`voice`, CONSTRAINT `voice_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`))') (SQL: INSERT INTO `voice` (`guild_id`, `user_id`) VALUES (%s, %s) ([612377874787336212, 234395307759108106]))
Allows users to add their birthday to the bot so that the bot celebrates their birthday
Modification to the $channelSummary
command that lets the user merge messages so that multiple messages over a short period of time show up as a single single message so text spam influences the stats less.
This could be done using a flag on the command or just a new command, honestly I don't know what's possible.
Orator was selected the ORM for this project for its simple design and syntax. Unfortunately, Orator never made it to a full release, and while the core of the framework worked, there were some workarounds that were needed for a small number of edge cases, mostly with migrations.
Masonite has been developed as an almost direct drop-in replacement for Orator, and is now in stable release.
This has been traced to being an issue with not handling reconnection logic, because the on_ready
event is fired every time the bot is reconnected and ready, causing multiple tasks to start
4|Discord | Exception in callback PollsCog.after_poll_daemon_end(<Task cancell...init__.py:88>>)
4|Discord | handle: <Handle PollsCog.after_poll_daemon_end(<Task cancell...init__.py:88>>)>
4|Discord | Traceback (most recent call last):
4|Discord | File "/usr/lib/python3.6/asyncio/events.py", line 145, in _run
4|Discord | self._callback(*self._args)
4|Discord | File "/data/Sheffield-Discord-Bot/cogs/polls.py", line 406, in after_poll_daemon_end
4|Discord | error = fut.exception()
4|Discord | concurrent.futures._base.CancelledError
Looks like this method wasn't triggered when I (r0bbi3#0269) joined.
This is likely caused by this setting being disabled.
This has left me with 0 roles in the server, and therefore no access to the rest of the server.
Perhaps it's better to place the lines of code that direct message the user in a try-except block, so the method doesn't throw an error before giving the user their "registering" role.
cogs/polls.py:400-401
needed to be removed
an appreciate command so a random active user will get pinged and appreciated
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.