Skip to content

Discord Integration

Gideon edited this page Nov 8, 2021 · 43 revisions

Setup

Create a new Discord Application and Bot for your server on Discord's Developer Portal.

To invite the Bot to your server, you must generate an OAuth2 URL with the correct permissions. Click on the OAuth2 tab in the sidebar, select bot under "Scopes," and grant your bot permissions. You will need at minimum:

  • Send Messages
  • Read Message History
  • Embed Links (for the neat embeds such as in $info.)

Under the Bot tab, make your bot private to prevent other people from inviting it to their servers and using your Switch.

  • Enable Privileged Gateway Intents and Server Members Intent under the same tab.

Before Starting

When you start the application by clicking the .exe, the Discord bot will be launched.

Configure the bot's settings on your server. If you only want it in a few specific channels, remove all the permissions on the bot's role itself and add the role to specific channels only. Ensure that you do not have any other roles that are restricting the bot's permissions (including the "everyone" role), and you enter any extra codes needed if you have 2FA enabled.

NOTE: You will need to restart the .exe for changes to take affect, after restarting you will also need to set the dodo code again.

Config

When SysBot.AnimalCrossing.exe is run for the first time, a template config.json and discord.json will be created in the same folder. They will look as follows:
Config.json:
Template config.json
Discord.json:
Template discord.json

config.json fields

  • AcceptingCommands: Boolean indicating whether or not your bot will accept commands, you will most likely want to leave this on true.

  • SkipConsoleBotCreation: Boolean indicating whether or not your bot will try to connect to a Switch, mostly for testing purposes for features that don't require a Switch to be connected

  • Offset: Inventory offset. Leave this at 0 if you wish to have your offset determined dynamically.

    • If you want to manually add your offset:
      • For the current version (v2.0.0) the offset should be 2943407840 if you have one player profile on your island.
      • If you have more than one player profile, use this formula to determine the offset: 2943407840 + (1161576 * (number of profiles on your island - 1)).
        • This formula only works for playing on the first profile.
  • ProfileCount: Amount of human profiles that are on your island.

    • Used to dynamically determine the right inventory offset; only used if Offset is left at 0.
  • RequireValidInventoryMetadata: Whether or not the inventory offset needs to be valid.

    • Leave this on true unless you really know what you're doing.
  • RequireJoin: Whether or not members are forced to use $join before using other commands.

  • MaxVisitorCount: The max amount of visitors that can be on your island at once.

    • Only counts people who used $join.
  • DropConfig: A subsection of the config file for dropping related settings.

    • Mode: Which dropping method to use.
      • 0: Legacy, drops items that can normally be dropped.
      • 1: New, drops items by overwriting right before attempting to drop a droppable-only item.
    • SkipDropCheck: Whether or not to skip checking if the supplied items are normally droppable.
    • AutoClean: Indicates whether or not the items surrounding the player character should be picked up while idle.
      • This may cause furniture close to the player character to be picked up when alone on the island.
    • NoActivitySeconds: The time in seconds before the bot autocleans if enabled.
    • MaxDropCount: The max amount of items users can drop in a single command.
    • PickupCount: The amount of items to pick up when cleaning.
    • WrapAllItems: Boolean indicating whether or not all items should be wrapped
      • Default is yes since this makes drop item the first option when selecting an item in-game, making the task more generic and faster.
    • WrappingPaper: Indicates which type of wrapping paper should be used.
  • FieldItemConfig: A subsection of the config related to spawning items.

    • FieldItemLayerPath: Path to a dumped .nhl file from NHSE.
    • FullRefreshCooldownMinutes: How often the bot should refresh the field.
    • InjectFieldItemLayer: Whether the bot should inject the .nhl file provided over your current layer.
    • InjectFieldItemRequest:
    • MaxSpawnCount: How many items can be spawned per message.
    • SpawnMaxHeight: The max vertical height of a drop.
    • SpawnSpacingX: Amount of tiles between drops on the X axis.
    • SpawnSpacingY: Amount of tiles between drops on the Y axis.
      • Must be equal to or higher than SpawnMaxHeight.
    • SpawnMinX: The minimum amount of tiles there need to be between your spawn and the left border.
      • For easy reading of tiles, use NHSE to easily navigate your map and see coordinates.
    • SpawnMinY: The minimum amount of tiles there need to be between your spawn and the top border.
    • SpawnMaxX: The minimum amount of tiles there need to be between your spawn and the right border.
    • SpawnMaxY: The minimum amount of tiles there need to be between your spawn and the bottom border.
    • Mode: The shape your spawn should try to make.
      • 0: Fills vertical untill it hits SpawnMaxHeight length, then creates a second vertical line to the right.
      • 1: Tries to create a square.
      • 2: Vertical columns only.
  • ViewConfig: Teleportation and dynamic session management.

    • AllowTeleportation: Toggles teleportation-related commands.
    • DodoCodeRetrieval: Allows the bot to open a session or check the dodo code itself on bot start-up if enabled.
      • Can still be used if AllowTeleportation is disabled.
    • SkipSessionCheck: Whether or not to check if a session actually exists.
      • If this is set to true while DodoCodeRetrieval is set to true, the bot will return nothing as the dodo code if a session doesn't already exist. If this is set to false, the bot will attempt to open your gates and start a session.
    • OverworldLoopCheckDelay: Bot will check if a session still exists and if bot is still in the right position every x milliseconds.
    • AirportX: X co-ordinate of your airport.
    • AirportY: Y co-ordinate of your airport.
    • DropX: X co-ordinate of the spot where you want your bot to drop items.
    • DropY: Y co-ordinate of the spot where you want your bot to drop items.
  • VillagerConfig: Villager injection.

    • AllowVillagerInjection: Whether or not users are allowed to inject villagers.
      • This will overwrite your existing villagers if enabled.
    • MinVillagerIndex: The lowest index villager to overwrite.
    • MaxVillagerIndex: The highest index villager to overwrite.
    • StaleSeconds: The minimum time between villager injections in seconds.
  • AllowClean: Boolean indicating whether or not $clean can be used to pick up items surrounding the player character.

  • AllowValidate: Boolean indicating whether or not $validate can be used to validate the inventory offset.

  • RestartOnCrash: Boolean indicating whether or not the bot should try to restart and reconnect on a crash.

  • MaximumRestarts: The maximum amount of times the bot should try to restart after a crash before giving up.

  • UptimeTreshold: Amount of time the bot must be connected before considered stable.

  • MaximumTransferSize: Allows you to set a cap on the amount of data being transferred to your Switch at once.

  • Protocol: Determines which protocol the bot will use to connect to your switch.

  • IP: The IP that should be connected to.

    • You can find this by going to the Homebrew Menu on your Switch and pressing Y.
  • Port: Port the bot will try to connect to, do not change this.

discord.json fields

  • Name: The name of your bot, seperate from the username and nickname your bot has in Discord.
    • This will also display in the playing status of your bot. It will say Playing followed by whatever you changed this variable to.
  • Token: The token of your Discord application, to request a token go to Discord's Developer Portal.
    • Do not share this token with other people, as it will allow them to run their own code on your bot account.
  • Prefix: Character before your message that indicates it's a command.
    • Default is $.
  • RoleUseBot: Name of the role required to use bot commands other than $help and $info.
    • Leaving this as the default @everyone will make it so no role is required.
  • Channels: List of channel IDs in which commands may be used.
    • Leaving this empty causes commands to be usable in any channel.
  • Users: List of user IDs that are allowed to use commands.
    • Leaving this empty causes anyone to be able to use commands.
  • Sudo: List of user IDs that are granted sudo access, allowing them to use commands in the Control Module.
  • ModuleBlacklist: List of modules you want to disable.

Examples

For comparison, here's what my config.json and discord.json looks like after filling out all the fields:
Config.json:
Example config.json
Discord.json:
Example discord.json