Skip to content

Commit 40bd6d7

Browse files
committed
refactor: remove more naff
1 parent 97483be commit 40bd6d7

File tree

12 files changed

+38
-45
lines changed

12 files changed

+38
-45
lines changed

interactions/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
ModalCommand,
215215
ModalContext,
216216
MODEL_TO_CONVERTER,
217-
NaffUser,
217+
ClientUser,
218218
NoArgumentConverter,
219219
NSFWLevel,
220220
open_file,
@@ -536,7 +536,7 @@
536536
"ModalCommand",
537537
"ModalContext",
538538
"MODEL_TO_CONVERTER",
539-
"NaffUser",
539+
"ClientUser",
540540
"NoArgumentConverter",
541541
"NSFWLevel",
542542
"open_file",

interactions/api/events/processors/_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import TYPE_CHECKING, Callable, Coroutine
55

66
from interactions.client.const import Absent, MISSING, AsyncCallable
7-
from interactions.models.discord.user import NaffUser
7+
from interactions.models.discord.user import ClientUser
88

99
if TYPE_CHECKING:
1010
from interactions.client.smart_cache import GlobalCache
@@ -43,7 +43,7 @@ class EventMixinTemplate:
4343
dispatch: Callable[["BaseEvent"], None]
4444
_init_interactions: Callable[[], Coroutine]
4545
synchronise_interactions: Callable[[], Coroutine]
46-
_user: NaffUser
46+
_user: ClientUser
4747
_guild_event: asyncio.Event
4848

4949
def __init__(self) -> None:

interactions/api/gateway/state.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import interactions
1010
from interactions.api import events
1111
from interactions.client.const import Absent, MISSING, get_logger
12-
from interactions.client.errors import NaffException, WebSocketClosed
12+
from interactions.client.errors import LibraryException, WebSocketClosed
1313
from interactions.models.discord.activity import Activity
1414
from interactions.models.discord.enums import Intents, Status, ActivityType
1515
from .gateway import GatewayClient
@@ -116,11 +116,11 @@ async def _ws_connect(self) -> None:
116116

117117
except WebSocketClosed as ex:
118118
if ex.code == 4011:
119-
raise NaffException("Your bot is too large, you must use shards") from None
119+
raise LibraryException("Your bot is too large, you must use shards") from None
120120
if ex.code == 4013:
121-
raise NaffException(f"Invalid Intents have been passed: {self.intents}") from None
121+
raise LibraryException(f"Invalid Intents have been passed: {self.intents}") from None
122122
if ex.code == 4014:
123-
raise NaffException(
123+
raise LibraryException(
124124
"You have requested privileged intents that have not been enabled or approved. Check the developer dashboard"
125125
) from None
126126
raise

interactions/client/auto_shard_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ async def login(self, token: str | None = None) -> None:
218218
Login to discord via http.
219219
220220
!!! note
221-
You will need to run Naff.start_gateway() before you start receiving gateway events.
221+
You will need to run Client.start_gateway() before you start receiving gateway events.
222222
223223
Args:
224224
token str: Your bot's token

interactions/client/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
GuildTemplate,
6464
Message,
6565
Extension,
66-
NaffUser,
66+
ClientUser,
6767
User,
6868
Member,
6969
Modal,
@@ -370,7 +370,7 @@ def __init__(
370370
else:
371371
self._activity: Activity = activity
372372

373-
self._user: Absent[NaffUser] = MISSING
373+
self._user: Absent[ClientUser] = MISSING
374374
self._app: Absent[Application] = MISSING
375375

376376
# collections
@@ -459,7 +459,7 @@ def gateway_started(self) -> bool:
459459
return self._connection_state.gateway_started.is_set()
460460

461461
@property
462-
def user(self) -> NaffUser:
462+
def user(self) -> ClientUser:
463463
"""Returns the bot's user."""
464464
return self._user
465465

@@ -636,7 +636,7 @@ async def on_command_error(self, event: events.CommandError) -> None:
636636
ctx=event.ctx,
637637
)
638638
)
639-
with contextlib.suppress(errors.NaffException):
639+
with contextlib.suppress(errors.LibraryException):
640640
if isinstance(event.error, errors.CommandOnCooldown):
641641
await event.ctx.send(
642642
embeds=Embed(
@@ -857,7 +857,7 @@ async def login(self, token: str | None = None) -> None:
857857
Login to discord via http.
858858
859859
!!! note
860-
You will need to run Naff.start_gateway() before you start receiving gateway events.
860+
You will need to run Client.start_gateway() before you start receiving gateway events.
861861
862862
Args:
863863
token str: Your bot's token
@@ -876,7 +876,7 @@ async def login(self, token: str | None = None) -> None:
876876

877877
self.logger.debug("Attempting to login")
878878
me = await self.http.login(self.token)
879-
self._user = NaffUser.from_dict(me, self)
879+
self._user = ClientUser.from_dict(me, self)
880880
self.cache.place_user_data(me)
881881
self._app = Application.from_dict(await self.http.get_current_bot_information(), self)
882882
self._mention_reg = re.compile(rf"^(<@!?{self.user.id}*>\s)")
@@ -1118,7 +1118,7 @@ def command(self, *args, **kwargs) -> Callable:
11181118

11191119
def listen(self, event_name: Absent[str] = MISSING) -> Callable[[AsyncCallable], Listener]:
11201120
"""
1121-
A decorator to be used in situations that Naff can't automatically hook your listeners. Ideally, the standard listen decorator should be used, not this.
1121+
A decorator to be used in situations that the library can't automatically hook your listeners. Ideally, the standard listen decorator should be used, not this.
11221122
11231123
Args:
11241124
event_name: The event name to use, if not the coroutine name

interactions/client/errors.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from interactions.models.discord.snowflake import Snowflake_Type
1313

1414
__all__ = (
15-
"NaffException",
15+
"LibraryException",
1616
"BotException",
1717
"GatewayNotFound",
1818
"LoginError",
@@ -50,15 +50,15 @@
5050
)
5151

5252

53-
class NaffException(Exception):
54-
"""Base Exception of Naff."""
53+
class LibraryException(Exception):
54+
"""Base Exception of i.py."""
5555

5656

57-
class BotException(NaffException):
57+
class BotException(LibraryException):
5858
"""An issue occurred in the client, likely user error."""
5959

6060

61-
class GatewayNotFound(NaffException):
61+
class GatewayNotFound(LibraryException):
6262
"""An exception that is raised when the gateway for Discord could not be found."""
6363

6464
def __init__(self) -> None:
@@ -69,7 +69,7 @@ class LoginError(BotException):
6969
"""The bot failed to login, check your token."""
7070

7171

72-
class HTTPException(NaffException):
72+
class HTTPException(LibraryException):
7373
"""
7474
A HTTP request resulted in an exception.
7575
@@ -193,11 +193,11 @@ class RateLimited(HTTPException):
193193
"""Discord is rate limiting this application."""
194194

195195

196-
class TooManyChanges(NaffException):
196+
class TooManyChanges(LibraryException):
197197
"""You have changed something too frequently."""
198198

199199

200-
class WebSocketClosed(NaffException):
200+
class WebSocketClosed(LibraryException):
201201
"""The websocket was closed."""
202202

203203
code: int = 0
@@ -224,7 +224,7 @@ def __init__(self, code: int) -> None:
224224
super().__init__(f"The Websocket closed with code: {code} - {self.codes.get(code, 'Unknown Error')}")
225225

226226

227-
class VoiceWebSocketClosed(NaffException):
227+
class VoiceWebSocketClosed(LibraryException):
228228
"""The voice websocket was closed."""
229229

230230
code: int = 0
@@ -251,7 +251,7 @@ def __init__(self, code: int) -> None:
251251
super().__init__(f"The Websocket closed with code: {code} - {self.codes.get(code, 'Unknown Error')}")
252252

253253

254-
class WebSocketRestart(NaffException):
254+
class WebSocketRestart(LibraryException):
255255
"""The websocket closed, and is safe to restart."""
256256

257257
resume: bool = False
@@ -394,7 +394,7 @@ class AlreadyResponded(AlreadyDeferred):
394394
"""An interaction was already responded to, and you attempted to defer it"""
395395

396396

397-
class ForeignWebhookException(NaffException):
397+
class ForeignWebhookException(LibraryException):
398398
"""Raised when you attempt to send using a webhook you did not create."""
399399

400400

@@ -416,7 +416,7 @@ def __init__(self) -> None:
416416
super().__init__("Bot is not connected to any voice channels in given guild")
417417

418418

419-
class VoiceConnectionTimeout(NaffException):
419+
class VoiceConnectionTimeout(LibraryException):
420420
"""Raised when the bot fails to connect to a voice channel."""
421421

422422
def __init__(self) -> None:

interactions/models/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
MessageType,
103103
MFALevel,
104104
Modal,
105-
NaffUser,
105+
ClientUser,
106106
NSFWLevel,
107107
open_file,
108108
OverwriteType,
@@ -466,7 +466,7 @@
466466
"ModalCommand",
467467
"ModalContext",
468468
"MODEL_TO_CONVERTER",
469-
"NaffUser",
469+
"ClientUser",
470470
"NoArgumentConverter",
471471
"NSFWLevel",
472472
"open_file",

interactions/models/discord/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
from .team import Team, TeamMember
162162
from .thread import ThreadList, ThreadMember, ThreadTag
163163
from .timestamp import Timestamp, TimestampStyles
164-
from .user import BaseUser, Member, NaffUser, User
164+
from .user import BaseUser, Member, User, ClientUser
165165
from .voice_state import VoiceRegion, VoiceState
166166

167167
__all__ = (
@@ -268,7 +268,7 @@
268268
"MessageType",
269269
"MFALevel",
270270
"Modal",
271-
"NaffUser",
271+
"ClientUser",
272272
"NSFWLevel",
273273
"open_file",
274274
"OverwriteType",

interactions/models/discord/user.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class FakeUserMixin(FakeBaseUserMixin):
7979
class User(FakeUserMixin, BaseUser): ...
8080

8181
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
82-
class NaffUser(User):
82+
class ClientUser(User):
8383
verified: bool
8484
mfa_enabled: bool
8585
email: Optional[str]

mkdocs.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,11 @@ watch:
5656
extra:
5757
social:
5858
- icon: fontawesome/brands/discord
59-
link: https://discord.gg/hpfNhH8BsY
59+
link: https://discord.gg/interactions
6060
name: Discord Server
6161
- icon: fontawesome/brands/github
62-
link: https://github.com/Discord-Snake-Pit/naff
62+
link: https://github.com/interactions-py/interactions.py
6363
name: Github Repository
64-
- icon: fontawesome/brands/trello
65-
link: https://trello.com/b/LVjnmYKt/dev-board
66-
name: Trello Board
6764
analytics:
6865
provider: google
6966
property: G-817ZC2FC56
@@ -100,10 +97,6 @@ plugins:
10097
- search
10198
- awesome-pages
10299
- autorefs
103-
# - git-committers:
104-
# repository: NAFTeam/NAFF
105-
# branch: docs-refresh
106-
# token: !ENV [GH_TOKEN]
107100
- git-revision-date-localized:
108101
fallback_to_build_date: true
109102
- mkdocstrings:

0 commit comments

Comments
 (0)